Remove after_initialize hook

pull/9609/head
Oliver Günther 3 years ago
parent 1fa9230c8e
commit 421335d103
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 6
      app/models/user_preference.rb
  2. 2
      spec/models/user_preference_spec.rb

@ -36,8 +36,6 @@ class UserPreference < ApplicationRecord
validates_presence_of :user
validate :time_zone_correctness, if: -> { time_zone.present? }
after_initialize :init_settings
##
# Retrieve keys from settings, and allow accessing
# as boolean with ? suffix
@ -137,10 +135,6 @@ class UserPreference < ApplicationRecord
%i[user user_id].include?(name.to_sym)
end
def init_settings
self.settings ||= {}
end
def time_zone_correctness
errors.add(:time_zone, :inclusion) if time_zone.present? && canonical_time_zone.nil?
end

@ -105,7 +105,7 @@ describe UserPreference do
:hide_mail?
context 'when a new pref instance' do
subject { UserPreference.new }
subject { described_class.new }
it 'defaults to true' do
expect(subject.settings[:hide_mail]).to be_nil

Loading…
Cancel
Save