diff options
Diffstat (limited to 'spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb')
-rw-r--r-- | spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb b/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb index 4eb2388f3f7..7afb80488d8 100644 --- a/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb +++ b/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb @@ -2,14 +2,12 @@ require "spec_helper" -RSpec.describe Gitlab::InactiveProjectsDeletionWarningTracker do +RSpec.describe Gitlab::InactiveProjectsDeletionWarningTracker, :freeze_time do let_it_be(:project_id) { 1 } describe '.notified_projects', :clean_gitlab_redis_shared_state do before do - freeze_time do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified - end + Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified end it 'returns the list of projects for which deletion warning email has been sent' do @@ -53,6 +51,46 @@ RSpec.describe Gitlab::InactiveProjectsDeletionWarningTracker do end end + describe '#notification_date', :clean_gitlab_redis_shared_state do + before do + Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + end + + it 'returns the date if a deletion warning email has been sent for a given project' do + expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).notification_date).to eq("#{Date.current}") + end + + it 'returns nil if a deletion warning email has not been sent for a given project' do + expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(2).notification_date).to eq(nil) + end + end + + describe '#scheduled_deletion_date', :clean_gitlab_redis_shared_state do + shared_examples 'returns the expected deletion date' do + it do + expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).scheduled_deletion_date) + .to eq(1.month.from_now.to_date.to_s) + end + end + + before do + stub_application_setting(inactive_projects_delete_after_months: 2) + stub_application_setting(inactive_projects_send_warning_email_after_months: 1) + end + + context 'without a stored deletion email date' do + it_behaves_like 'returns the expected deletion date' + end + + context 'with a stored deletion email date' do + before do + Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + end + + it_behaves_like 'returns the expected deletion date' + end + end + describe '#reset' do before do Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified |