Sha256: f61f411b51807c2092c9d1fae9bda6e7c75db4a0428b7981cc069057460d3c3c

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

class TokenAuthenticatableTest < ActiveSupport::TestCase

  test 'should reset authentication token' do
    user = new_user
    user.reset_authentication_token
    previous_token = user.authentication_token
    user.reset_authentication_token
    assert_not_equal previous_token, user.authentication_token
  end

  test 'should ensure authentication token' do
    user = new_user
    user.ensure_authentication_token
    previous_token = user.authentication_token
    user.ensure_authentication_token
    assert_equal previous_token, user.authentication_token
  end

  test 'should authenticate a valid user with authentication token and return it' do
    user = create_user
    user.ensure_authentication_token!
    user.confirm!
    authenticated_user = User.find_for_token_authentication(:auth_token => user.authentication_token)
    assert_equal authenticated_user, user
  end

  test 'should return nil when authenticating an invalid user by authentication token' do
    user = create_user
    user.ensure_authentication_token!
    user.confirm!
    authenticated_user = User.find_for_token_authentication(:auth_token => user.authentication_token.reverse)
    assert_nil authenticated_user
  end

end

Version data entries

16 entries across 16 versions & 6 rubygems

Version Path
devise-1.1.7 test/models/token_authenticatable_test.rb
devise-1.1.6 test/models/token_authenticatable_test.rb
devise-jdguyot-1.2.rc test/models/token_authenticatable_test.rb
devise-1.1.5 test/models/token_authenticatable_test.rb
devise-1.1.4 test/models/token_authenticatable_test.rb
devise-1.2.rc test/models/token_authenticatable_test.rb
aihs_devise-1.2.rc test/models/token_authenticatable_test.rb
gonow-devise-1.2.rc test/models/token_authenticatable_test.rb
devise-edge-1.2.rc test/models/token_authenticatable_test.rb
devise-1.1.3 test/models/token_authenticatable_test.rb
devise-1.1.2 test/models/token_authenticatable_test.rb
devise-1.1.1 test/models/token_authenticatable_test.rb
devise-1.1.0 test/models/token_authenticatable_test.rb
namxam-devise-1.1.0.win test/models/token_authenticatable_test.rb
devise-1.1.rc2 test/models/token_authenticatable_test.rb
devise-1.1.rc1 test/models/token_authenticatable_test.rb