Sha256: a753f0d7be66e5904cf7143d67b9327c3344bb7792efdaf7de8dea0cd610fc48

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require 'test_helper'

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

  test "remember_token" do
    @user.remember_me!
    assert_not_nil @user.remember_token
    assert_not_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!
    assert_not_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

4 entries across 4 versions & 1 rubygems

Version Path
janus-0.9.1 test/unit/rememberable_test.rb
janus-0.9.0 test/unit/rememberable_test.rb
janus-0.8.1 test/unit/rememberable_test.rb
janus-0.8.0 test/unit/rememberable_test.rb