Sha256: 9aa0ee71967b50b7d5e586094ad85603a52fed103102efe6d971f69ab3684b2e

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'test_helper'

class Users::TokenAuthenticatableTest < ActionDispatch::IntegrationTest
  fixtures :all

  setup do
    @user = users(:julien)
    @user.reset_authentication_token!
  end

  test "should sign user in from token" do
    visit root_url(:auth_token => @user.authentication_token)
    assert_authenticated
  end

  test "should not sign user with invalid token" do
    visit root_url(:auth_token => 'unknown token')
    assert_not_authenticated
  end

  test "should reuse token" do
    Janus::Config.stub(:reusable_authentication_token, true) do
      token = @user.authentication_token
      visit root_url(:auth_token => token)
      sign_out :user

      visit root_url(:auth_token => token)
      assert_authenticated
    end
  end

  test "shouldn't reuse token" do
    Janus::Config.stub(:reusable_authentication_token, false) do
      token = @user.authentication_token
      visit root_url(:auth_token => token)
      sign_out :user

      visit root_url(:auth_token => token)
      assert_not_authenticated
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
janus-0.9.1 test/integration/users/token_authenticatable_test.rb
janus-0.9.0 test/integration/users/token_authenticatable_test.rb
janus-0.8.1 test/integration/users/token_authenticatable_test.rb
janus-0.8.0 test/integration/users/token_authenticatable_test.rb