Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove after_initialize hook

Oliver Günther421335d103f7
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 740e5f46b81..faeee96a44d 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.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
diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb
index 16c02555fcc..dfb0de7c4a0 100644
--- a/spec/models/user_preference_spec.rb
+++ b/spec/models/user_preference_spec.rb
@@ -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