2019-02-02 22:16:11 +01:00
|
|
|
RSpec.describe TrustedDeviceToken, type: :model do
|
|
|
|
describe '#token_valid?' do
|
2020-07-20 17:05:04 +02:00
|
|
|
let(:token) { create(:trusted_device_token) }
|
2019-02-02 22:16:11 +01:00
|
|
|
|
|
|
|
context 'when the token is create after login_token_validity' do
|
|
|
|
it { expect(token.token_valid?).to be true }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the token is create before login_token_validity' do
|
|
|
|
before { token.update(created_at: (TrustedDeviceToken::LOGIN_TOKEN_VALIDITY + 1.minute).ago) }
|
|
|
|
|
|
|
|
it { expect(token.token_valid?).to be false }
|
|
|
|
end
|
|
|
|
end
|
2019-02-04 11:04:55 +01:00
|
|
|
|
|
|
|
describe '#token_young?' do
|
2020-07-20 17:05:04 +02:00
|
|
|
let(:token) { create(:trusted_device_token) }
|
2019-02-04 11:04:55 +01:00
|
|
|
|
|
|
|
context 'when the token is create after login_token_youth' do
|
|
|
|
it { expect(token.token_young?).to be true }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the token is create before login_token_youth' do
|
|
|
|
before { token.update(created_at: (TrustedDeviceToken::LOGIN_TOKEN_YOUTH + 1.minute).ago) }
|
|
|
|
|
|
|
|
it { expect(token.token_young?).to be false }
|
|
|
|
end
|
|
|
|
end
|
2019-02-02 22:16:11 +01:00
|
|
|
end
|