Sha256: 52e8809f89b5e224f3c22ee82dad7be80151e764c7d181392b9c87fe14901780

Contents?: true

Size: 1.02 KB

Versions: 31

Compression:

Stored size: 1.02 KB

Contents

require "test_helper"

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

  def default_headers
    { "Authorization" => "Bearer #{@token}" }
  end

  test "should get index" do
    get sessions_url, headers: default_headers
    assert_response :success
  end

  test "should show session" do
    get session_url(@user.sessions.last), headers: default_headers
    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_response :created
  end

  test "should not sign in with wrong credentials" do
    post sign_in_url, params: { email: @user.email, password: "SecretWrong1*3" }
    assert_response :unauthorized
  end

  test "should sign out" do
    delete session_url(@user.sessions.last), headers: default_headers
    assert_response :no_content
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
authentication-zero-2.15.1 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.15.0 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.14.0 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.13.0 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.12.6 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.12.5 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.12.4 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.12.3 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.12.2 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.12.1 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt
authentication-zero-2.12.0 lib/generators/authentication/templates/test_unit/controllers/api/sessions_controller_test.rb.tt