490da89281b7ee019c87406fb8ce7359aff0932cEugen Kuksarequire 'spec_helper'
490da89281b7ee019c87406fb8ce7359aff0932cEugen Kuksa
490da89281b7ee019c87406fb8ce7359aff0932cEugen Kuksadescribe AccessToken do
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa let(:access_token) { create :access_token }
68ff70f830e958de6693000b9652c9aa8cff97e7Eugen Kuksa let(:repository) { create :repository }
68ff70f830e958de6693000b9652c9aa8cff97e7Eugen Kuksa
68ff70f830e958de6693000b9652c9aa8cff97e7Eugen Kuksa before do
4de867f5bf046eb83029341a4b6520c7cac42274Eugen Kuksa repository.access_tokens << access_token
68ff70f830e958de6693000b9652c9aa8cff97e7Eugen Kuksa repository.save
68ff70f830e958de6693000b9652c9aa8cff97e7Eugen Kuksa end
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa context 'expired?' do
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa it 'should not be expired when the expiration date is in the future' do
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa expect(access_token.expired?).to be_falsy
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa end
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa it 'should be expired when the expiration date is in the past' do
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa access_token.expiration = (-1).minutes.from_now
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa expect(access_token.expired?).to be_truthy
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa end
9dd500e3acdc343dbefcaf88b7663db25be0ef46Eugen Kuksa end
490da89281b7ee019c87406fb8ce7359aff0932cEugen Kuksaend