|
25 | 25 | jsonrpc_success "You just foo and bar like it just don't matter" |
26 | 26 | end |
27 | 27 |
|
| 28 | + chatop :proxy_parameters, |
| 29 | + /(?:proxy_parameters)/, |
| 30 | + "proxy parameters back to test" do |
| 31 | + response = { :params => params, :jsonrpc_params => jsonrpc_params }.to_json |
| 32 | + jsonrpc_success response |
| 33 | + end |
| 34 | + |
28 | 35 | skip_before_action :ensure_method_exists, only: :non_chatop_method |
29 | 36 | def non_chatop_method |
30 | 37 | render :plain => "Why would you have something thats not a chatop?" |
@@ -228,6 +235,12 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil) |
228 | 235 | "regex" => /(?:how can i foo and bar all at once)?/.source, |
229 | 236 | "params" => [], |
230 | 237 | "path" => "foobar" |
| 238 | + }, |
| 239 | + "proxy_parameters" => { |
| 240 | + "help" => "proxy parameters back to test", |
| 241 | + "regex" => /(?:proxy_parameters)/.source, |
| 242 | + "params" => [], |
| 243 | + "path" => "proxy_parameters" |
231 | 244 | } |
232 | 245 | }, |
233 | 246 | "version" => "3" |
@@ -293,6 +306,26 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil) |
293 | 306 | expect(response.status).to eq 200 |
294 | 307 | end |
295 | 308 |
|
| 309 | + it "passes all expected paramters" do |
| 310 | + rails_flexible_post :execute_chatop, { |
| 311 | + :chatop => "proxy_parameters", |
| 312 | + :user => "foo", |
| 313 | + :mention_slug => "mention_slug_here", |
| 314 | + :message_id => "message_id_here", |
| 315 | + :room_id => "#someroom", |
| 316 | + :unknown_key => "few" # This should get ignored |
| 317 | + }, { |
| 318 | + "app" => "foo" |
| 319 | + } |
| 320 | + expect(json_response).to eq({ |
| 321 | + "jsonrpc" => "2.0", |
| 322 | + "id" => nil, |
| 323 | + "result" => "{\"params\":{\"action\":\"proxy_parameters\",\"chatop\":\"proxy_parameters\",\"controller\":\"anonymous\",\"mention_slug\":\"mention_slug_here\",\"message_id\":\"message_id_here\",\"room_id\":\"#someroom\",\"user\":\"foo\"},\"jsonrpc_params\":{\"app\":\"foo\"}}" |
| 324 | + }) |
| 325 | + expect(response.status).to eq 200 |
| 326 | + end |
| 327 | + |
| 328 | + |
296 | 329 | it "uses typical controller fun like before_action" do |
297 | 330 | rails_flexible_post :execute_chatop, :chatop => "wcid", :user => "foo" |
298 | 331 | expect(json_response).to eq({ |
@@ -360,6 +393,15 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil) |
360 | 393 | expect(request.params["params"]["this-is-sparta"]).to eq "true" |
361 | 394 | end |
362 | 395 |
|
| 396 | + it "sends along all the parameters" do |
| 397 | + chat "where can i deploy foobar", "my_username", "room_id_5", "message_id_6" |
| 398 | + expect(request.params["action"]).to eq "execute_chatop" |
| 399 | + expect(request.params["chatop"]).to eq "wcid" |
| 400 | + expect(request.params["user"]).to eq "my_username" |
| 401 | + expect(request.params["room_id"]).to eq "room_id_5" |
| 402 | + expect(request.params["message_id"]).to eq "message_id_6" |
| 403 | + end |
| 404 | + |
363 | 405 | it "anchors regexes" do |
364 | 406 | expect { |
365 | 407 | chat "too bad that this message doesn't start with where can i deploy foobar", "bhuga" |
|
0 commit comments