summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-14 05:45:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-14 05:45:16 +0000
commit09375960d69dcca6dafe4b126b77994f523efba8 (patch)
tree263680473e25b24e4e6410d258bf3ac902a137a0 /test
parent354e09811b5d044afb6152efa2cdd38bdeac60a4 (diff)
downloadredmine-09375960d69dcca6dafe4b126b77994f523efba8.tar.gz
redmine-09375960d69dcca6dafe4b126b77994f523efba8.zip
When copying issues, let the status be changed to default or left unchanged.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9404 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb44
-rw-r--r--test/unit/issue_test.rb8
2 files changed, 37 insertions, 15 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 484880cc7..1b0224dfb 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -3065,24 +3065,38 @@ class IssuesControllerTest < ActionController::TestCase
end
end
assert_redirected_to '/projects/ecookbook/issues'
+
+ copies = Issue.all(:order => 'id DESC', :limit => issues.size)
+ copies.each do |copy|
+ assert_equal 2, copy.project_id
+ end
end
def test_bulk_copy_should_allow_not_changing_the_issue_attributes
@request.session[:user_id] = 2
- issue_before_move = Issue.find(1)
- assert_difference 'Issue.count', 1 do
- assert_no_difference 'Project.find(1).issues.count' do
- post :bulk_update, :ids => [1], :copy => '1',
- :issue => {
- :project_id => '2', :tracker_id => '', :assigned_to_id => '',
- :status_id => '', :start_date => '', :due_date => ''
- }
- end
+ issues = [
+ Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1, :priority_id => 2, :subject => 'issue 1', :author_id => 1, :assigned_to_id => nil),
+ Issue.create!(:project_id => 2, :tracker_id => 3, :status_id => 2, :priority_id => 1, :subject => 'issue 2', :author_id => 2, :assigned_to_id => 3)
+ ]
+
+ assert_difference 'Issue.count', issues.size do
+ post :bulk_update, :ids => issues.map(&:id), :copy => '1',
+ :issue => {
+ :project_id => '', :tracker_id => '', :assigned_to_id => '',
+ :status_id => '', :start_date => '', :due_date => ''
+ }
+ end
+
+ copies = Issue.all(:order => 'id DESC', :limit => issues.size)
+ issues.each do |orig|
+ copy = copies.detect {|c| c.subject == orig.subject}
+ assert_not_nil copy
+ assert_equal orig.project_id, copy.project_id
+ assert_equal orig.tracker_id, copy.tracker_id
+ assert_equal orig.status_id, copy.status_id
+ assert_equal orig.assigned_to_id, copy.assigned_to_id
+ assert_equal orig.priority_id, copy.priority_id
end
- issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
- assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id
- assert_equal issue_before_move.status_id, issue_after_move.status_id
- assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id
end
def test_bulk_copy_should_allow_changing_the_issue_attributes
@@ -3097,7 +3111,7 @@ class IssuesControllerTest < ActionController::TestCase
post :bulk_update, :ids => [1, 2], :copy => '1',
:issue => {
:project_id => '2', :tracker_id => '', :assigned_to_id => '4',
- :status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
+ :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31'
}
end
end
@@ -3107,7 +3121,7 @@ class IssuesControllerTest < ActionController::TestCase
copied_issues.each do |issue|
assert_equal 2, issue.project_id, "Project is incorrect"
assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
- assert_equal 3, issue.status_id, "Status is incorrect"
+ assert_equal 1, issue.status_id, "Status is incorrect"
assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
end
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index ddebbee19..b55b3d065 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -395,6 +395,14 @@ class IssueTest < ActiveSupport::TestCase
assert_equal expected_statuses, issue.new_statuses_allowed_to(admin)
end
+ def test_new_statuses_allowed_to_should_return_default_and_current_status_when_copying
+ issue = Issue.find(1).copy
+ assert_equal [1], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
+
+ issue = Issue.find(2).copy
+ assert_equal [1, 2], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
+ end
+
def test_copy
issue = Issue.new.copy_from(1)
assert issue.copy?