jeudi 15 décembre 2016

How do I test a Rails action with frozen strings as parameters?

I have an error in a Rails 4.2.7.1 controller action where I modify the incoming parameter:

params[:temperature].gsub!(',', '.')

Until recently this worked, but it fails in development and production now:

can't modify frozen String

I have a fix for the problem, but I have no test that uncovers the error. Both my controller test and integration test succeed with the faulty code, and I see that the parameters are not frozen in the controller even if they are frozen when posted from the test.

How can I ensure frozen parameters arrive in the controller in my test?

Aucun commentaire:

Enregistrer un commentaire