@@ -40,7 +40,7 @@ def ensure_app_given
4040 before :each do
4141 routes . draw do
4242 get "/_chatops" => "anonymous#list"
43- post "/_chatops/:action " , controller : "anonymous"
43+ post "/_chatops/:chatop " , controller : "anonymous" , action : :execute_chatop
4444 get "/other" => "anonymous#non_chatop_method"
4545 get "/other_will_fail" => "anonymous#unexcluded_chatop_method"
4646 end
@@ -121,7 +121,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
121121 end
122122
123123 it "requires a user be sent to chatops" do
124- post :foobar
124+ rails_flexible_post :execute_chatop , chatop : :foobar
125125 expect ( response . status ) . to eq 400
126126 expect ( json_response ) . to eq ( {
127127 "jsonrpc" => "2.0" ,
@@ -134,7 +134,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
134134 end
135135
136136 it "returns method not found for a not found method" do
137- rails_flexible_post :barfoo , :user => "foo"
137+ rails_flexible_post :execute_chatop , chatop : :barfoo , user : "foo"
138138 expect ( json_response ) . to eq ( {
139139 "jsonrpc" => "2.0" ,
140140 "id" => nil ,
@@ -160,7 +160,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
160160 end
161161
162162 it "runs a known method" do
163- rails_flexible_post :foobar , :user => "foo"
163+ rails_flexible_post :execute_chatop , chatop : :foobar , user : "foo"
164164 expect ( json_response ) . to eq ( {
165165 "jsonrpc" => "2.0" ,
166166 "id" => nil ,
@@ -170,7 +170,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
170170 end
171171
172172 it "passes parameters to methods" do
173- rails_flexible_post :wcid , { :user => "foo" } , { "app" => "foo" }
173+ rails_flexible_post :execute_chatop , { :chatop => "wcid" , :user => "foo" } , { "app" => "foo" }
174174 expect ( json_response ) . to eq ( {
175175 "jsonrpc" => "2.0" ,
176176 "id" => nil ,
@@ -180,7 +180,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
180180 end
181181
182182 it "uses typical controller fun like before_action" do
183- rails_flexible_post :wcid , :user => "foo"
183+ rails_flexible_post :execute_chatop , :chatop => " wcid" , :user => "foo"
184184 expect ( json_response ) . to eq ( {
185185 "jsonrpc" => "2.0" ,
186186 "id" => nil ,
@@ -193,7 +193,7 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
193193 end
194194
195195 it "allows methods to return invalid params with a message" do
196- rails_flexible_post :wcid , { :user => "foo" } , { "app" => "nope" }
196+ rails_flexible_post :execute_chatop , { :chatop => "wcid" , :user => "foo" } , { "app" => "nope" }
197197 expect ( response . status ) . to eq 400
198198 expect ( json_response ) . to eq ( {
199199 "jsonrpc" => "2.0" ,
@@ -220,15 +220,17 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
220220 context "regex-based test helpers" do
221221 it "routes based on regexes from test helpers" do
222222 chat "where can i deploy foobar" , "bhuga"
223- expect ( request . params [ "action" ] ) . to eq "wcid"
223+ expect ( request . params [ "action" ] ) . to eq "execute_chatop"
224+ expect ( request . params [ "chatop" ] ) . to eq "wcid"
224225 expect ( request . params [ "user" ] ) . to eq "bhuga"
225226 expect ( request . params [ "params" ] [ "app" ] ) . to eq "foobar"
226227 expect ( chatop_response ) . to eq "You can deploy foobar just fine."
227228 end
228229
229230 it "works with generic arguments" do
230231 chat "where can i deploy foobar --fruit apple --vegetable green celery" , "bhuga"
231- expect ( request . params [ "action" ] ) . to eq "wcid"
232+ expect ( request . params [ "action" ] ) . to eq "execute_chatop"
233+ expect ( request . params [ "chatop" ] ) . to eq "wcid"
232234 expect ( request . params [ "user" ] ) . to eq "bhuga"
233235 expect ( request . params [ "params" ] [ "app" ] ) . to eq "foobar"
234236 expect ( request . params [ "params" ] [ "fruit" ] ) . to eq "apple"
@@ -238,7 +240,8 @@ def rails_flexible_post(path, outer_params, jsonrpc_params = nil)
238240
239241 it "works with boolean arguments" do
240242 chat "where can i deploy foobar --this-is-sparta" , "bhuga"
241- expect ( request . params [ "action" ] ) . to eq "wcid"
243+ expect ( request . params [ "action" ] ) . to eq "execute_chatop"
244+ expect ( request . params [ "chatop" ] ) . to eq "wcid"
242245 expect ( request . params [ "user" ] ) . to eq "bhuga"
243246 expect ( request . params [ "params" ] [ "this-is-sparta" ] ) . to eq "true"
244247 end
0 commit comments