Sha256: 829c7254950ba4d9e1ff953a270e79f8ab8e3db1b138e061b388cccdcc0b1a01

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require "test_helper"

class SessionsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
  end

  test "should get index" do
    sign_in_as @<%= singular_table_name %>

    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: @<%= singular_table_name %>.email, password: "Secret1*3*5*" }
    assert_enqueued_email_with SessionMailer, :signed_in_notification, args: { session: @<%= singular_table_name %>.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: @<%= singular_table_name %>.email, password: "SecretWrong1*3" }
    assert_redirected_to sign_in_url(email_hint: @<%= singular_table_name %>.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 @<%= singular_table_name %>

    delete session_url(@<%= singular_table_name %>.sessions.last)
    assert_redirected_to sessions_url

    follow_redirect!
    assert_redirected_to sign_in_url
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
authentication-zero-2.11.2 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.11.1 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.11.0 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.10.0 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
authentication-zero-2.9.3 lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt