Max
Max

Reputation: 15955

Testing Rails' new strong parameters

I've just upgraded to Rails 4, and I have started using strong parameters over protected attributes. I typically tested a models protected attributes using unit tests, but I am unsure how to test now that this functionality has been moved to the controller.

I am using rspec for testing. Any advice would be great.

Upvotes: 0

Views: 165

Answers (1)

varatis
varatis

Reputation: 14740

Why not just do

post :create, model: { someattrs }
response.response_code.should == 400

In your controller spec?

Upvotes: 3

Related Questions