Testing strong parameters

Hi guys,

Has anyone figured out how to test strong parameters?

You mean test the concept itself, or test that your usage of it does what you intend? I haven't done so, but offhand, I would guess you could do that by testing a few requests with good or bad parameter sets, and seeing whether Rails gritches about them or not.

-Dave

They all pass. That’s the problem. Mass-assignment doesn’t seem to get caught by the testing environment.

Ah, yes, that is odd. Maybe you could check out the tests from that part of Rails, or of the strong_parameters gem, and see how they do it.

-Dave

LOL! Thx Dave.

Anyone else figured/figuring this out or found some documentation about it?

Use permitters instead. Easily testable.

What have you got

config.action_controller.action_on_unpermitted_parameters

set to?

I set it to :raise in test/development, so that submitting incorrect parameters will cause tests to fail

Fred

Thx Fredrick! You’re a STAR!