summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-20 18:22:43 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-20 18:22:43 +0000
commitfbf30eec7c58786d615852bc17ffe5a1c49229b6 (patch)
treeff3e3183f87dcb2f18ea02e33b3a154501c5b980 /test
parent8a3623733fa2ef879bb2a3f4355e0ce0df49b278 (diff)
downloadredmine-fbf30eec7c58786d615852bc17ffe5a1c49229b6.tar.gz
redmine-fbf30eec7c58786d615852bc17ffe5a1c49229b6.zip
Adds an option of the copy form to enable/disable attachments copy (#3055).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8677 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb40
1 files changed, 39 insertions, 1 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 55c4cb932..7bc0d7119 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -1631,6 +1631,24 @@ class IssuesControllerTest < ActionController::TestCase
assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
end
+ def test_new_as_copy_with_attachments_should_show_copy_attachments_checkbox
+ @request.session[:user_id] = 2
+ issue = Issue.find(3)
+ assert issue.attachments.count > 0
+ get :new, :project_id => 1, :copy_from => 3
+
+ assert_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
+ end
+
+ def test_new_as_copy_without_attachments_should_not_show_copy_attachments_checkbox
+ @request.session[:user_id] = 2
+ issue = Issue.find(3)
+ issue.attachments.delete_all
+ get :new, :project_id => 1, :copy_from => 3
+
+ assert_no_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'}
+ end
+
def test_new_as_copy_with_invalid_issue_should_respond_with_404
@request.session[:user_id] = 2
get :new, :project_id => 1, :copy_from => 99999
@@ -1664,7 +1682,8 @@ class IssuesControllerTest < ActionController::TestCase
assert_difference 'Attachment.count', count do
assert_no_difference 'Journal.count' do
post :create, :project_id => 1, :copy_from => 3,
- :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}
+ :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
+ :copy_attachments => '1'
end
end
end
@@ -1673,6 +1692,24 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort
end
+ def test_create_as_copy_without_copy_attachments_option_should_not_copy_attachments
+ @request.session[:user_id] = 2
+ issue = Issue.find(3)
+ count = issue.attachments.count
+ assert count > 0
+
+ assert_difference 'Issue.count' do
+ assert_no_difference 'Attachment.count' do
+ assert_no_difference 'Journal.count' do
+ post :create, :project_id => 1, :copy_from => 3,
+ :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}
+ end
+ end
+ end
+ copy = Issue.first(:order => 'id DESC')
+ assert_equal 0, copy.attachments.count
+ end
+
def test_create_as_copy_with_attachments_should_add_new_files
@request.session[:user_id] = 2
issue = Issue.find(3)
@@ -1684,6 +1721,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_no_difference 'Journal.count' do
post :create, :project_id => 1, :copy_from => 3,
:issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'},
+ :copy_attachments => '1',
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
end
end