force set default document category if it is not set on database (#11665)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10221 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
185ab2a020
commit
665a331cc4
|
@ -31,4 +31,12 @@ class DocumentCategory < Enumeration
|
|||
def transfer_relations(to)
|
||||
documents.update_all("category_id = #{to.id}")
|
||||
end
|
||||
|
||||
def self.default
|
||||
d = super
|
||||
if d.nil?
|
||||
d = find(:first)
|
||||
end
|
||||
d
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,4 +38,8 @@ class DocumentCategoryTest < ActiveSupport::TestCase
|
|||
e.update_attributes(:is_default => true)
|
||||
assert_equal 3, DocumentCategory.default.id
|
||||
end
|
||||
|
||||
def test_force_default
|
||||
assert_equal 1, DocumentCategory.default.id
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue