diff options
author | Sean McGivern <sean@gitlab.com> | 2017-07-28 10:44:33 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-07-31 11:18:55 +0100 |
commit | 57a5544f883ad9687c38270519edc7914912af5d (patch) | |
tree | cf7713439a19e40d2c0b69fff197d3db0a74c8ed /app/models/notification_setting.rb | |
parent | 4c89929fb4211aa1cf5f311a0cec89988de45184 (diff) | |
download | gitlab-ce-57a5544f883ad9687c38270519edc7914912af5d.tar.gz |
Remove events column from notification settings33620-remove-events-from-notification_settings
This was migrated to separate columns in 9.4, and now just needs to be removed
for real.
Diffstat (limited to 'app/models/notification_setting.rb')
-rw-r--r-- | app/models/notification_setting.rb | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb index 81844b1e2ca..9b1cac64c44 100644 --- a/app/models/notification_setting.rb +++ b/app/models/notification_setting.rb @@ -1,4 +1,8 @@ class NotificationSetting < ActiveRecord::Base + include IgnorableColumn + + ignore_column :events + enum level: { global: 3, watch: 2, mention: 4, participating: 1, disabled: 0, custom: 5 } default_value_for :level, NotificationSetting.levels[:global] @@ -41,9 +45,6 @@ class NotificationSetting < ActiveRecord::Base :success_pipeline ].freeze - store :events, coder: JSON - before_save :convert_events - def self.find_or_create_for(source) setting = find_or_initialize_by(source: source) @@ -54,42 +55,17 @@ class NotificationSetting < ActiveRecord::Base setting end - # 1. Check if this event has a value stored in its database column. - # 2. If it does, return that value. - # 3. If it doesn't (the value is nil), return the value from the serialized - # JSON hash in `events`. - (EMAIL_EVENTS - [:failed_pipeline]).each do |event| - define_method(event) do - bool = super() - - bool.nil? ? !!events[event] : bool - end - - alias_method :"#{event}?", event - end - # Allow people to receive failed pipeline notifications if they already have # custom notifications enabled, as these are more like mentions than the other # custom settings. def failed_pipeline bool = super - bool = events[:failed_pipeline] if bool.nil? bool.nil? || bool end alias_method :failed_pipeline?, :failed_pipeline def event_enabled?(event) - respond_to?(event) && public_send(event) - end - - def convert_events - return if events_before_type_cast.nil? - - EMAIL_EVENTS.each do |event| - write_attribute(event, public_send(event)) - end - - write_attribute(:events, nil) + respond_to?(event) && !!public_send(event) end end |