Sha256: b99f915d96e8e3b1f551f442864462bff00a7efca58ecad855b6b8b7828be628

Contents?: true

Size: 1.42 KB

Versions: 33

Compression:

Stored size: 1.42 KB

Contents

require 'test_helper'

class TimeoutableTest < ActiveSupport::TestCase

  test 'should be expired' do
    assert new_user.timedout?(31.minutes.ago)
  end

  test 'should not be expired' do
    assert_not new_user.timedout?(29.minutes.ago)
  end

  test 'should not be expired when params is nil' do
    assert_not new_user.timedout?(nil)
  end

  test 'should use timeout_in method' do
    user = new_user
    user.instance_eval { def timeout_in; 10.minutes end }

    assert user.timedout?(12.minutes.ago)
    assert_not user.timedout?(8.minutes.ago)
  end

  test 'should not be expired when timeout_in method returns nil' do
    user = new_user
    user.instance_eval { def timeout_in; nil end }
    assert_not user.timedout?(10.hours.ago)
  end

  test 'fallback to Devise config option' do
    swap Devise, timeout_in: 1.minute do
      user = new_user
      assert user.timedout?(2.minutes.ago)
      assert_not user.timedout?(30.seconds.ago)

      Devise.timeout_in = 5.minutes
      assert_not user.timedout?(2.minutes.ago)
      assert user.timedout?(6.minutes.ago)
    end
  end

  test 'required_fields should contain the fields that Devise uses' do
    assert_same_content Devise::Models::Timeoutable.required_fields(User), []
  end

  test 'should not raise error if remember_created_at is not empty and rememberable is disabled' do
    user = create_admin(remember_created_at: Time.current)
    assert user.timedout?(31.minutes.ago)
  end
end

Version data entries

33 entries across 33 versions & 6 rubygems

Version Path
devise-3.5.10 test/models/timeoutable_test.rb
devise-4.0.3 test/models/timeoutable_test.rb
devise-4.1.1 test/models/timeoutable_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/devise-4.1.0/test/models/timeoutable_test.rb
devise-4.1.0 test/models/timeoutable_test.rb
devise-3.5.9 test/models/timeoutable_test.rb
devise-4.0.2 test/models/timeoutable_test.rb
devise-4.0.1 test/models/timeoutable_test.rb
devise-3.5.8 test/models/timeoutable_test.rb
devise-3.5.7 test/models/timeoutable_test.rb
devise-4.0.0 test/models/timeoutable_test.rb
devise-4.0.0.rc2 test/models/timeoutable_test.rb
devise-4.0.0.rc1 test/models/timeoutable_test.rb
devise-3.5.6 test/models/timeoutable_test.rb
devise-3.5.5 test/models/timeoutable_test.rb
devise-3.5.4 test/models/timeoutable_test.rb
devise-3.5.3 test/models/timeoutable_test.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/devise-3.5.2/test/models/timeoutable_test.rb
devise-3.5.2 test/models/timeoutable_test.rb
devise-3.5.1 test/models/timeoutable_test.rb