I have a simple controller test based on Rails 4 docs (using Test :: Unit):
test "should create user" do assert_difference('User.count') do post :create, user: users(:sample_user) end assert_redirected_to user_path(assigns(:user)) end
And, despite the fact that the actual user is created just fine, the test does not work, saying:
1) Error: UsersControllerTest # test_should_create_user: NoMethodError: undefined method permit' for "832959492":String app/controllers/users_controller.rb:23:in user_params' app / controllers / users_controller.rb: 8: in the create' test/controllers/users_controller_test.rb:11:in block create' test/controllers/users_controller_test.rb:11:in (2 levels) in 'test / controllers / users_controller_test.rb: 10: in a block in
For some reason, the test does not recognize the new Rails 4 permit method. Right now I have user_params as a private method in the controller. But I tried moving it to a valid create action and got the same error. User creation is also 100% standard (not crazy at all - just like Rails docs).
Does anyone know how I can rewrite or otherwise pass this test?
source share