diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/auth_source_ldap.rb | 3 | ||||
-rw-r--r-- | app/models/custom_value.rb | 3 | ||||
-rw-r--r-- | app/models/document.rb | 3 | ||||
-rw-r--r-- | app/models/issue.rb | 3 | ||||
-rw-r--r-- | app/models/issue_relation.rb | 3 | ||||
-rw-r--r-- | app/models/query.rb | 4 | ||||
-rw-r--r-- | app/models/time_entry.rb | 3 | ||||
-rw-r--r-- | app/models/wiki_page.rb | 3 |
8 files changed, 14 insertions, 11 deletions
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index b7ab0cf30..76b1c25f4 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -27,7 +27,8 @@ class AuthSourceLdap < AuthSource before_validation :strip_ldap_attributes - def after_initialize + def initialize(attributes=nil, *args) + super self.port = 389 if self.port == 0 end diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb index dae8f73ef..6cb4853f9 100644 --- a/app/models/custom_value.rb +++ b/app/models/custom_value.rb @@ -21,7 +21,8 @@ class CustomValue < ActiveRecord::Base validate :validate_custom_value - def after_initialize + def initialize(attributes=nil, *args) + super if new_record? && custom_field && (customized_type.blank? || (customized && customized.new_record?)) self.value ||= custom_field.default_value end diff --git a/app/models/document.rb b/app/models/document.rb index f8ea92a11..208b10876 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -36,7 +36,8 @@ class Document < ActiveRecord::Base !user.nil? && user.allowed_to?(:view_documents, project) end - def after_initialize + def initialize(attributes=nil, *args) + super if new_record? self.category ||= DocumentCategory.default end diff --git a/app/models/issue.rb b/app/models/issue.rb index 199efe119..aa1a3b93c 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -124,7 +124,8 @@ class Issue < ActiveRecord::Base end end - def after_initialize + def initialize(attributes=nil, *args) + super if new_record? # set default values for new records only self.status ||= IssueStatus.default diff --git a/app/models/issue_relation.rb b/app/models/issue_relation.rb index 854e4255b..28b525ff5 100644 --- a/app/models/issue_relation.rb +++ b/app/models/issue_relation.rb @@ -57,7 +57,8 @@ class IssueRelation < ActiveRecord::Base (issue_to.nil? || user.allowed_to?(:manage_issue_relations, issue_to.project))) end - def after_initialize + def initialize(attributes=nil, *args) + super if new_record? if relation_type.blank? self.relation_type = IssueRelation::TYPE_RELATES diff --git a/app/models/query.rb b/app/models/query.rb index 4cd8d36b9..262a738d1 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -166,10 +166,6 @@ class Query < ActiveRecord::Base def initialize(attributes=nil, *args) super attributes self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} } - end - - def after_initialize - # Store the fact that project is nil (used in #editable_by?) @is_for_all = project.nil? end diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index c5c1d39bc..caa1019e5 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -65,7 +65,8 @@ class TimeEntry < ActiveRecord::Base end } - def after_initialize + def initialize(attributes=nil, *args) + super if new_record? && self.activity.nil? if default_activity = TimeEntryActivity.default self.activity_id = default_activity.id diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 92b72af8f..c6e5f21ed 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -55,7 +55,8 @@ class WikiPage < ActiveRecord::Base # Wiki pages that are protected by default DEFAULT_PROTECTED_PAGES = %w(sidebar) - def after_initialize + def initialize(attributes=nil, *args) + super if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase) self.protected = true end |