]> source.dussan.org Git - redmine.git/commitdiff
force set default document category if it is not set on database (#11665)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 21 Aug 2012 13:45:53 +0000 (13:45 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 21 Aug 2012 13:45:53 +0000 (13:45 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10221 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/document_category.rb
test/unit/document_category_test.rb

index a7a2fd9d6449c36244df4dce11c9181be9db8bf6..c22b81e5b112eee43be4b56d4adb79e0df3529d2 100644 (file)
@@ -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
index d3d3978bff295e7733690ff5cc09d82404d1474e..30ef1687ac22cf3ebb1f28fc810efe6a5a1cc31c 100644 (file)
@@ -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