Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5|Last
Lessons:- Edit Form

For convenience, the code in Listing 9.5 uses a helper to sign in a user inside the tests. The method is to visit the signin page and submit valid information, as shown in Listing 9.6

 

As noted in the comment line, filling in the form doesn’t work when not using Capybara, so to cover this case we also add the user’s remember token to the cookies:

# Sign in when not using Capybara as well.
cookies  [:remember token] =  user.remember token

 

This is necessary when using one of the HTTP request methods directly (get, post, put, or Delete), as we’ll see in Listing 9.47. (Note that the test cookies object isn’t a perfect simulation of the real cookies object; in particular, the cookies.permanent method seen in Listing 8.19 doesn’t work inside tests.) As you might suspect, the sign_in method will prove useful in future tests, and in fact it can already be used to eliminate some duplication (Section 9.6).

       The application code to add the URI for the ‘‘Settings’’ link is simple: We just use the named route edit_user_path from Table 7.1, together with the handy current_user helper method defined in Listing 8.22:

<%=  link to  "Settings", edit user path(current user)  %>  

 

 

 
 
 
image
Pooja   Negi

Skills    Ruby On Rails

Qualifications :- High School - SSN high school, College/University - HNBGU, College/University - SRHU,
Location :-Ranipokhari,Rishikesh,Uttarakhand,India
Description:- Student
Explore
 

  Students (0)