mirror of
https://github.com/redmine/redmine.git
synced 2025-11-02 11:25:55 +01:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user