diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 17:36:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 17:36:54 +0300 |
commit | f61bb2a16a514b71bf33aabbbb999d6732016a24 (patch) | |
tree | 9548caa89e60b4f40b99bbd1dac030420b812aa8 /spec/models/key_spec.rb | |
parent | 35fc54e5d261f8898e390aea7c2f5ec5fdf0539d (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc42
Diffstat (limited to 'spec/models/key_spec.rb')
-rw-r--r-- | spec/models/key_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 3d33a39d353..0cb20efcb0a 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -75,6 +75,28 @@ RSpec.describe Key, :mailer do .to eq([key_3, key_1, key_2]) end end + + context 'expiration scopes' do + let_it_be(:user) { create(:user) } + let_it_be(:expired_today_not_notified) { create(:key, expires_at: Time.current, user: user) } + let_it_be(:expired_today_already_notified) { create(:key, expires_at: Time.current, user: user, expiry_notification_delivered_at: Time.current) } + let_it_be(:expired_yesterday) { create(:key, expires_at: 1.day.ago, user: user) } + let_it_be(:expiring_soon_unotified) { create(:key, expires_at: 3.days.from_now, user: user) } + let_it_be(:expiring_soon_notified) { create(:key, expires_at: 4.days.from_now, user: user, before_expiry_notification_delivered_at: Time.current) } + let_it_be(:future_expiry) { create(:key, expires_at: 1.month.from_now, user: user) } + + describe '.expired_today_and_not_notified' do + it 'returns keys that expire today' do + expect(described_class.expired_today_and_not_notified).to contain_exactly(expired_today_not_notified) + end + end + + describe '.expiring_soon_and_not_notified' do + it 'returns keys that will expire soon' do + expect(described_class.expiring_soon_and_not_notified).to contain_exactly(expiring_soon_unotified) + end + end + end end context "validation of uniqueness (based on fingerprint uniqueness)" do |