I was trying to pass the exercise in listing 10.56 and test if the admin attribute is forbidden. I added admin parameter in
app/controllers/users_controller.rb
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation,
:admin)
end
also, filled necessary parts in
test/controllers/users_controller_test.rb
test "should not allow the admin attribute to be edited via the web" do
log_in_as(@other_user)
assert_not @other_user.admin?
patch :update, id: @other_user, user: { password: "",
password_confirmation: "",
admin: true }
assert_not @other_user.reload.admin?
end
Still, I am getting unknown error after test:
ERROR["test_should_not_allow_the_admin_attribute_to_be_edited_via_the_web", UsersControllerTest, 3.2600422599352896]
test_should_not_allow_the_admin_attribute_to_be_edited_via_the_web#UsersControllerTest (3.26s)
URI::InvalidURIError: URI::InvalidURIError: bad URI(is not URI?): http://www.example.com:80update
test/controllers/users_controller_test.rb:37:in `block in <class:UsersControllerTest>'
Anyone here was dealing with the same problem?
Many thanks for any help)
Aucun commentaire:
Enregistrer un commentaire