"Remember Me" integration check failed.

I am following railstutorial.org, 3rd edition, and I am currently working on Chapter 8: Log In, Log Out .

I found the problem in Listing 8.51 (logging in without remembering the test):

assert_nil cookies['remember_token'] 

When I execute: rake test , it returns RED with the following error:

 FAIL["test_login_without_remembering", UsersLoginTest, 1.268578948] test_login_without_remembering#UsersLoginTest (1.27s) Expected "" to be nil. test/integration/users_login_test.rb:46:in 'block in <class:UsersLoginTest>' 

Otherwise, when I go to the next code, it returns GREEN and the process of logging in - logging out of the system works as expected.

 assert_not_nil cookies['remember_token'] 

Anyone facing the same problem can explain this case?

Thanks.

+8
ruby ruby-on-rails cookies session-cookies
source share
1 answer

I just made this mistake ...

TL; DR; remove remember user from sessions_controller.rb


Take a look at listing 8.34 . You should find remember user in session_controller.rb .

Now referring to the same file, see Listing 8.49 . The author does a great job on this line, but if you just insert it without deleting the remember user call, the token will still be generated.

So, when pasting into this line:

params[:session][:remember_me] == '1' ? remember(user) : forget(user)

make sure it replaces the call with remember user .

+21
source share

All Articles