@@ -1,5 +1,5 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
@@ -43,6 +43,14 class IssueRelation < ActiveRecord::Base | |||||
43 |
|
43 | |||
44 | attr_protected :issue_from_id, :issue_to_id |
|
44 | attr_protected :issue_from_id, :issue_to_id | |
45 |
|
45 | |||
|
46 | def after_initialize | |||
|
47 | if new_record? | |||
|
48 | if relation_type.blank? | |||
|
49 | self.relation_type = IssueRelation::TYPE_RELATES | |||
|
50 | end | |||
|
51 | end | |||
|
52 | end | |||
|
53 | ||||
46 | def validate |
|
54 | def validate | |
47 | if issue_from && issue_to |
|
55 | if issue_from && issue_to | |
48 | errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id |
|
56 | errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id |
@@ -1,5 +1,5 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
@@ -32,6 +32,12 class IssueRelationTest < ActiveSupport::TestCase | |||||
32 | assert_equal to, relation.issue_to |
|
32 | assert_equal to, relation.issue_to | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
|
35 | def test_create_minimum | |||
|
36 | relation = IssueRelation.new :issue_from => Issue.find(1), :issue_to => Issue.find(2) | |||
|
37 | assert relation.save | |||
|
38 | assert_equal IssueRelation::TYPE_RELATES, relation.relation_type | |||
|
39 | end | |||
|
40 | ||||
35 | def test_follows_relation_should_be_reversed |
|
41 | def test_follows_relation_should_be_reversed | |
36 | from = Issue.find(1) |
|
42 | from = Issue.find(1) | |
37 | to = Issue.find(2) |
|
43 | to = Issue.find(2) |
General Comments 0
You need to be logged in to leave comments.
Login now