diff options
author | Sean McGivern <sean@gitlab.com> | 2016-07-07 14:41:48 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-07-07 22:49:17 +0300 |
commit | ea25e0918b77c2345585a968fbf5b73bb544aac7 (patch) | |
tree | 372a006af02dd94a7dcc958007e7c0335b4cac42 /spec/models | |
parent | 3c89a788c795fba2b050a0af0d8261e302d8cded (diff) |
Exclude projects pending delete from notifications
If the Sidekiq job fails for some reason, a project can be 'stuck'
pending deletion. The project can't be viewed, so it shouldn't be
available through the notification settings association as this will
throw an exception when we try to show the link.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/notification_setting_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index df336a6effe..d58673413c8 100644 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -38,4 +38,21 @@ RSpec.describe NotificationSetting, type: :model do end end end + + describe '#for_projects' do + let(:user) { create(:user) } + + before do + 1.upto(4) do |i| + setting = create(:notification_setting, user: user) + + setting.project.update_attributes(pending_delete: true) if i.even? + end + end + + it 'excludes projects pending delete' do + expect(user.notification_settings.for_projects).to all(have_attributes(project: an_instance_of(Project))) + expect(user.notification_settings.for_projects.map(&:project)).to all(have_attributes(pending_delete: false)) + end + end end |