Sha256: ccbc985a9acf2326e9c91e473ad3f39eaa3af8e72cab7e56a3db619daf0d58e2

Contents?: true

Size: 948 Bytes

Versions: 3

Compression:

Stored size: 948 Bytes

Contents

require 'spec_helper'
require 'authenticate/model/lifetimed'


describe Authenticate::Model::Lifetimed do

  context '#max_session_lifetime_exceeded?' do
    before {
      Authenticate.configure do |config|
        config.max_session_lifetime = 10.minutes
      end
    }

    it 'passes fresh sessions' do
      user = create(:user, current_sign_in_at: 1.minute.ago.utc)
      expect(user).to_not be_max_session_lifetime_exceeded
    end

    it 'detects timed out sessions' do
      user = create(:user, current_sign_in_at: 5.hours.ago.utc)
      expect(user).to be_max_session_lifetime_exceeded
    end

    describe 'max_session_lifetime param not set' do
      it 'does not time out' do
        user = create(:user, current_sign_in_at: 5.hours.ago.utc)
        Authenticate.configure do |config|
          config.max_session_lifetime = nil
        end
        expect(user).to_not be_max_session_lifetime_exceeded
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authenticate-0.2.3 spec/model/lifetimed_spec.rb
authenticate-0.2.2 spec/model/lifetimed_spec.rb
authenticate-0.2.1 spec/model/lifetimed_spec.rb