Skip to content

Instantly share code, notes, and snippets.

@rbarazi
Created April 7, 2010 02:26
Show Gist options
  • Save rbarazi/358421 to your computer and use it in GitHub Desktop.
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
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