summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-07-07 20:17:24 +0000
committerRobert Speicher <robert@gitlab.com>2016-07-07 20:17:24 +0000
commit91cf0387dd91b380647457c41edd948a357b620c (patch)
tree1c671215783980e1ed3e49c42ef8dda5d1004735 /spec/models
parent68155ee73b549a4f79744bb325542c29d45c71ea (diff)
parentea25e0918b77c2345585a968fbf5b73bb544aac7 (diff)
downloadgitlab-ce-91cf0387dd91b380647457c41edd948a357b620c.tar.gz
Merge branch 'pending-delete-project-notifications' into 'master'
Exclude projects pending delete from notifications Make `NotificationSetting.for_projects` exclude projects that are excluded by the default scope on `Project`. (At the moment, that's projects with `pending_delete: true`.) See https://gitlab.com/gitlab-com/support-forum/issues/819 See merge request !5138
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/notification_setting_spec.rb17
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