summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-27 19:09:30 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-09-27 19:09:30 +0000
commitcc4cff9f11b453c6fe308da6867819b4717e8d1a (patch)
treed2677bbc67877f5879a4ff3392e32bcf7c0fbfc0 /test
parentc3e055bd700bdcd09c700d20d1c309b55e46a0e8 (diff)
downloadredmine-cc4cff9f11b453c6fe308da6867819b4717e8d1a.tar.gz
redmine-cc4cff9f11b453c6fe308da6867819b4717e8d1a.zip
Adds a "Copied from/to" relation when copying issue(s) (#6899).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10491 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb26
-rw-r--r--test/unit/issue_test.rb13
2 files changed, 39 insertions, 0 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index fdd995c56..b6e583fda 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -2357,6 +2357,19 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal count + 1, copy.attachments.count
end
+ def test_create_as_copy_should_add_relation_with_copied_issue
+ @request.session[:user_id] = 2
+
+ assert_difference 'Issue.count' do
+ assert_difference 'IssueRelation.count' do
+ post :create, :project_id => 1, :copy_from => 1,
+ :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
+ end
+ end
+ copy = Issue.first(:order => 'id DESC')
+ assert_equal 1, copy.relations.size
+ end
+
def test_create_as_copy_should_copy_subtasks
@request.session[:user_id] = 2
issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
@@ -3512,6 +3525,19 @@ class IssuesControllerTest < ActionController::TestCase
end
end
+ def test_bulk_copy_should_add_relations_with_copied_issues
+ @request.session[:user_id] = 2
+
+ assert_difference 'Issue.count', 2 do
+ assert_difference 'IssueRelation.count', 2 do
+ post :bulk_update, :ids => [1, 3], :copy => '1',
+ :issue => {
+ :project_id => '1'
+ }
+ end
+ end
+ end
+
def test_bulk_copy_should_allow_not_copying_the_subtasks
issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
@request.session[:user_id] = 2
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index fc08313bc..7fdd9cf0f 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -636,6 +636,19 @@ class IssueTest < ActiveSupport::TestCase
assert_equal orig.status, issue.status
end
+ def test_copy_should_add_relation_with_copied_issue
+ copied = Issue.find(1)
+ issue = Issue.new.copy_from(copied)
+ assert issue.save
+ issue.reload
+
+ assert_equal 1, issue.relations.size
+ relation = issue.relations.first
+ assert_equal 'copied_to', relation.relation_type
+ assert_equal copied, relation.issue_from
+ assert_equal issue, relation.issue_to
+ end
+
def test_copy_should_copy_subtasks
issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')