Sha256: d809be81dd76f50277e64402dca5fa3ee814b63bc27225d6043082a8e0a81a40

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

class RememberableTest < ActiveSupport::TestCase
  setup do
    @user = users(:julien)
  end

  test "remember_token" do
    @user.remember_me!
    refute_nil @user.remember_token
    refute_nil @user.remember_created_at

    @user.forget_me!
    assert_nil @user.remember_token
    assert_nil @user.remember_created_at
  end

  test "should not remember across browsers" do
    @user.remember_me!
    token = @user.remember_token
    @user.remember_me!
    refute_equal token, @user.remember_token
  end

  test "find_for_remember_authentication" do
    assert_nil User.find_for_remember_authentication(nil)
    assert_nil User.find_for_remember_authentication(" ")

    @user.remember_me!
    token = @user.remember_token

    assert_equal @user, User.find_for_remember_authentication(token)
    assert_equal @user, User.find_for_remember_authentication(token)

    @user.remember_me!
    assert_nil User.find_for_remember_authentication(token), "token should no longer be valid"

    @user.forget_me!
    assert_nil User.find_for_remember_authentication(token), "token should have been erased"
  end

  test "expiration" do
    @user.remember_me!
    @user.update_attribute(:remember_created_at, 1.year.ago)
    assert_nil User.find_for_remember_authentication(@user.remember_token)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
janus-0.10.1 test/unit/rememberable_test.rb
janus-0.10.0 test/unit/rememberable_test.rb