ruby on rails - Railstutorial.org Michael Hartl chapter 9 exercise 3 "should not allow the admin attribute to be edited via the web" -
I have started learning rail, and I got stuck on Chapter 9 third practice.
Exercise looks like this: My problem is that the I also created I thought that was correct: But it seems that the @other_moder is not being modified, so I think the error is at the end. My answer is wrong, I can not get this test to fail, this is because in the last claim I do not know what to put in the FILL_IN section I tried to cut FILL_IN but it does not work. After making changes to the underlying record, you must reload the frequency variable. It will load in new changes.
test should not allow "administrator attribute to be edited through the web" log_in_as (@ Other_user) Assert_not @ other_user.admin? Patches: Updates, IDs: @other_users, user: {password: FILL_IN, password_confirmation: FILL_IN, administrator: FILL_IN} assert_not @other_user.FILL_IN.admin? End
last FIL_IN & gt; & Gt; Assert_not @ other_user.FILL_IN.admin ?
@other_user is taken from stability and looks like this:
Archer: Name: Sterling Archer Email: duchess@example.gov password_digest: & lt;% = User.digest ('password')%>
Update action looks like this:
def update = user = user.find (params [: id]) If @ User.update_attributes (user_params) Flash [: success] = "profile updated" redirect_to @user else render 'edit and end'
: admin < / code> User_params can be modified at
: Administrator param :
def user_params params.require (: user) .permit (: name,: email,: Password: Password_confirmation, admin) end
test " Do not allow to edit from "Log_In_se (@other_user) assert_not @other_user.admin? Patches: Updates, IDs: @other_users, user: {password: @other_ger Password, password_confirmation: @other_user.password_confirmation, administrator: correct} assert_not @ other_user.admin?
"assert_not @other_user.FILL_IN.admin?"
assert_not @ other_user.reload.admin?
Comments
Post a Comment