]> source.dussan.org Git - redmine.git/commitdiff
Set a default value for relation type.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 4 Jul 2011 17:29:33 +0000 (17:29 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 4 Jul 2011 17:29:33 +0000 (17:29 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6177 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_relation.rb
test/unit/issue_relation_test.rb

index 751ac357915a5eed8c79b29b94065d1afee288f6..c66103c51986eaaf953f4ac5336ab1d71717c7c9 100644 (file)
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006-2007  Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2011  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -43,6 +43,14 @@ class IssueRelation < ActiveRecord::Base
   
   attr_protected :issue_from_id, :issue_to_id
   
+  def after_initialize
+    if new_record?
+      if relation_type.blank?
+        self.relation_type = IssueRelation::TYPE_RELATES
+      end
+    end
+  end
+  
   def validate
     if issue_from && issue_to
       errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
index 7f1581a26f07ec5c9890593a5516093cd3760bba..3c8347b45de874d83b5d0f5395bca7e95f2437c8 100644 (file)
@@ -1,5 +1,5 @@
 # Redmine - project management software
-# Copyright (C) 2006-2009  Jean-Philippe Lang
+# Copyright (C) 2006-2011  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -32,6 +32,12 @@ class IssueRelationTest < ActiveSupport::TestCase
     assert_equal to, relation.issue_to
   end
   
+  def test_create_minimum
+    relation = IssueRelation.new :issue_from => Issue.find(1), :issue_to => Issue.find(2)
+    assert relation.save
+    assert_equal IssueRelation::TYPE_RELATES, relation.relation_type
+  end
+  
   def test_follows_relation_should_be_reversed
     from = Issue.find(1)
     to = Issue.find(2)