Created
April 7, 2010 02:26
-
-
Save rbarazi/358421 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 10-21. Logout integration test, in test/integration/user_stories_test.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class UserStoriesTest < ActionDispatch::IntegrationTest | |
fixtures :all | |
test "should login user and redirect" do | |
get login_path | |
assert_response :success | |
assert_template 'new' | |
post session_path, :email => 'eugene@example.com', :password => 'secret' | |
assert_response :redirect | |
assert_redirected_to root_path | |
follow_redirect! | |
assert_response :success | |
assert_template 'index' | |
assert session[:user_id] | |
end | |
test "should logout user and redirect" do | |
get logout_path | |
assert_response :redirect | |
assert_redirected_to root_path | |
assert_nil session[:user] | |
follow_redirect! | |
assert_template 'index' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment