NOTE
I know, that
action
is reserved word in Rails. I am implementing a third party API for Yandex Money in a Rails server and the Yandex API app is posting anaction
param into my Rails application. I know how get it (How to not use Rails action parameter in controller). The issue is - how write test to my controller, because my test can't sendaction
parameter (see description below).
I'm writing controller tests in Rails, and I need pass action
parameters to the controller from test. This is my controller:
class YandexController < ApplicationController
def notify
render text: request.request_parameters
end
end
When I POST data with curl
command:
curl --data "action=paymentAviso&some_other_param=value" http://localhost:3000/yandex/notify
I get correct result:
{"action"=>"paymentAviso", "some_other_param"=>"value"}
But when I try send action
parameter in test then it is not working. See my test below:
class YandexControllerTest < ActionController::TestCase
test "notify sucess" do
post :notify, { action: 'paymentAviso', some_other_param: 'value' }
assert_response :success
puts response.body
end
end
And when I run test I see:
Running:
{"some_other_param"=>"value"}
Is there a way to pass action
parameter to my controller from test?