Sha256: c99bed11b838e2cd70ecfeda9a7b7a594eba974c9169114044499090634f3472

Contents?: true

Size: 1.14 KB

Versions: 31

Compression:

Stored size: 1.14 KB

Contents

require "test_helper"

class SessionsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @user = users(:lazaro_nixon)
  end

  test "should get index" do
    sign_in_as @user

    get sessions_url
    assert_response :success
  end

  test "should get new" do
    get sign_in_url
    assert_response :success
  end

  test "should sign in" do
    post sign_in_url, params: { email: @user.email, password: "Secret1*3*5*" }
    assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session: @user.sessions.last }

    assert_redirected_to root_url

    get root_url
    assert_response :success
  end

  test "should not sign in with wrong credentials" do
    post sign_in_url, params: { email: @user.email, password: "SecretWrong1*3" }
    assert_redirected_to sign_in_url(email_hint: @user.email)
    assert_equal "That email or password is incorrect", flash[:alert]

    get root_url
    assert_redirected_to sign_in_url
  end

  test "should sign out" do
    sign_in_as @user

    delete session_url(@user.sessions.last)
    assert_redirected_to sessions_url

    follow_redirect!
    assert_redirected_to sign_in_url
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
authentication-zero-2.16.11 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.10 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.9 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.8 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.7 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.6 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.5 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.4 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.3 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.2 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.1 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.16.0 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.9 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.8 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.7 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.6 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.5 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.4 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.3 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.15.2 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt