summaryrefslogtreecommitdiff
path: root/spec/models/notification_setting_spec.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-06-08 17:10:35 +0100
committerSean McGivern <sean@gitlab.com>2017-06-15 15:15:13 +0100
commite94c1028c1e829f899b0d0f56313cc62df6f9a0a (patch)
treed69f40f69e1ed69ce5c2c6d7fe2367ccca7cdce1 /spec/models/notification_setting_spec.rb
parentf4b5fcbca100769b89e6b06e0df180012d16a7a8 (diff)
downloadgitlab-ce-e94c1028c1e829f899b0d0f56313cc62df6f9a0a.tar.gz
Deserialise existing custom notification settingsdeserialize-custom-notifications
Create a post-deployment migration to update all existing notification settings with at least one custom level enabled to the new format. Also handle the same conversion when updating settings, to catch any stragglers.
Diffstat (limited to 'spec/models/notification_setting_spec.rb')
-rw-r--r--spec/models/notification_setting_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb
index d58673413c8..cc235ad467e 100644
--- a/spec/models/notification_setting_spec.rb
+++ b/spec/models/notification_setting_spec.rb
@@ -55,4 +55,34 @@ RSpec.describe NotificationSetting, type: :model do
expect(user.notification_settings.for_projects.map(&:project)).to all(have_attributes(pending_delete: false))
end
end
+
+ describe 'event_enabled?' do
+ before do
+ subject.update!(user: create(:user))
+ end
+
+ context 'for an event with a matching column name' do
+ before do
+ subject.update!(events: { new_note: true }.to_json)
+ end
+
+ it 'returns the value of the column' do
+ subject.update!(new_note: false)
+
+ expect(subject.event_enabled?(:new_note)).to be(false)
+ end
+
+ context 'when the column has a nil value' do
+ it 'returns the value from the events hash' do
+ expect(subject.event_enabled?(:new_note)).to be(false)
+ end
+ end
+ end
+
+ context 'for an event without a matching column name' do
+ it 'returns false' do
+ expect(subject.event_enabled?(:foo_event)).to be(false)
+ end
+ end
+ end
end