Shoulda - Passing parameters to controller actions
-
06-03-2021 - |
Вопрос
I've recently run into interesting problem passing parameters to my controller action from my functional test. Previously, I was passing the 'type' parameter (which is required by STI) like that and it worked:
setup do
get :new, :type => "TimeOfUseTariff"
end
However things have changed and i now need to pass something[type]. I've tried the following but nothing seems to work:
setup do
get :new, "something[type]" => "TimeOfUseTariff"
end
Neither:
setup do
get :new, "something[type]".constantize => "TimeOfUseTariff"
end
Is there any way how I can achieve passing this extra parameter?
Решение
This should work if the controller expects "something[type]":
setup do
get :new, :something => {:type => "TimeOfUseTariff"}
end
Не связан с StackOverflow