models: require belong_to associations on trusted_device_token
This commit is contained in:
parent
d807700c7b
commit
71d9774d58
3 changed files with 8 additions and 3 deletions
|
@ -12,7 +12,7 @@ class TrustedDeviceToken < ApplicationRecord
|
||||||
LOGIN_TOKEN_VALIDITY = 1.week
|
LOGIN_TOKEN_VALIDITY = 1.week
|
||||||
LOGIN_TOKEN_YOUTH = 15.minutes
|
LOGIN_TOKEN_YOUTH = 15.minutes
|
||||||
|
|
||||||
belongs_to :instructeur
|
belongs_to :instructeur, optional: false
|
||||||
has_secure_token
|
has_secure_token
|
||||||
|
|
||||||
def token_valid?
|
def token_valid?
|
||||||
|
|
5
spec/factories/trusted_device_token.rb
Normal file
5
spec/factories/trusted_device_token.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FactoryBot.define do
|
||||||
|
factory :trusted_device_token do
|
||||||
|
association :instructeur
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
RSpec.describe TrustedDeviceToken, type: :model do
|
RSpec.describe TrustedDeviceToken, type: :model do
|
||||||
describe '#token_valid?' do
|
describe '#token_valid?' do
|
||||||
let(:token) { TrustedDeviceToken.create }
|
let(:token) { create(:trusted_device_token) }
|
||||||
|
|
||||||
context 'when the token is create after login_token_validity' do
|
context 'when the token is create after login_token_validity' do
|
||||||
it { expect(token.token_valid?).to be true }
|
it { expect(token.token_valid?).to be true }
|
||||||
|
@ -14,7 +14,7 @@ RSpec.describe TrustedDeviceToken, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#token_young?' do
|
describe '#token_young?' do
|
||||||
let(:token) { TrustedDeviceToken.create }
|
let(:token) { create(:trusted_device_token) }
|
||||||
|
|
||||||
context 'when the token is create after login_token_youth' do
|
context 'when the token is create after login_token_youth' do
|
||||||
it { expect(token.token_young?).to be true }
|
it { expect(token.token_young?).to be true }
|
||||||
|
|
Loading…
Reference in a new issue