Sha256: dcf6995dc089edaa72c13e20fb22079cacf4933ecd272da6528542eac13e138a

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'integration_test_helper'

class LoginTest < ActionDispatch::IntegrationTest
  include ::CurrentUser::NavigationHelper

  fixtures :all

  test "unauthorized user sees the 401 error page" do
    visit '/my_protected_page'
    assert_user_sees_unauthorized_error
  end

  test "repeated successful login process" do
    sign_in_as 'admin@my.app.com'
    sign_in_as 'member@some.app.com'
  end

  test "sign in page does sign out" do
    sign_in_as 'member@some.app.com'
    visit sing_in_page_path
    visit '/my_protected_page'
    assert_user_sees_unauthorized_error
  end

  test "stored location" do
    visit '/my_another_protected_page'
    assert_user_sees_unauthorized_error
    sign_in
    assert page.has_content?("My another protected page"), 'Redirects to the stored location'
  end

  test "erasing the previous stored location" do
    visit '/my_another_protected_page'
    sign_in
    assert page.has_content?("My another protected page"), 'Redirects to the stored location'

    sign_in
    assert page.has_content?("My protected page"), 'Redirects to the default root url'
  end

  test "invalid key" do
    invalid_key = '54321'
    visit sing_in_page_path(invalid_key)
    assert_user_sees_unauthorized_error
  end

  test "empty users table" do
    ::User.destroy_all

    visit sing_in_page_path

    assert page.has_content?("Your database doesn't contain users."),
           'Show a message about an empty user table'
  end

  test "logout" do
    sign_in_as "member@some.app.com"
    visit 'current_user/sign_out'

    visit '/my_protected_page'
    assert_user_sees_unauthorized_error
  end

  test "all users in the application database are listed in the signin page" do end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
current_user-0.2.1 test/integration/login_test.rb
current_user-0.2.0 test/integration/login_test.rb