Add configurable setting for copying attachments when copying an issue (#36197).

Patch by Yuichi HARADA (user:yui.har).


git-svn-id: https://svn.redmine.org/redmine/trunk@22926 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2024-07-14 01:49:53 +00:00
parent 6322650728
commit 6c8b04d6d5
7 changed files with 115 additions and 5 deletions

View File

@@ -5624,6 +5624,47 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
def test_create_as_copy_should_always_copy_attachments_by_settings
assert_equal 4, Issue.find(3).attachments.size
with_settings :copy_attachments_on_issue_copy => 'yes' do
@request.session[:user_id] = 2
assert_difference 'Issue.count' do
assert_difference 'Attachment.count', 4 do
post(
:create,
:params => {
:project_id => 1,
:copy_from => 3,
:issue => {
:subject => 'Copy'
}
}
)
end
end
end
end
def test_create_as_copy_should_never_copy_attachments_by_settings
with_settings :copy_attachments_on_issue_copy => 'no' do
@request.session[:user_id] = 2
assert_difference 'Issue.count' do
assert_no_difference 'Attachment.count' do
post(
:create,
:params => {
:project_id => 1,
:copy_from => 3,
:issue => {
:subject => 'Copy'
}
}
)
end
end
end
end
def test_create_as_copy_should_copy_subtasks
@request.session[:user_id] = 2
issue = Issue.generate_with_descendants!
@@ -8085,6 +8126,47 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
def test_bulk_copy_should_never_copy_attachments_by_settings
with_settings :copy_attachments_on_issue_copy => 'no' do
@request.session[:user_id] = 2
assert_difference 'Issue.count' do
assert_no_difference 'Attachment.count' do
post(
:bulk_update,
:params => {
:ids => [3],
:copy => '1',
:issue => {
:project_id => ''
}
}
)
end
end
end
end
def test_bulk_copy_should_always_copy_attachments_by_settings
assert_equal 4, Issue.find(3).attachments.size
with_settings :copy_attachments_on_issue_copy => 'yes' do
@request.session[:user_id] = 2
assert_difference 'Issue.count' do
assert_difference 'Attachment.count', 4 do
post(
:bulk_update,
:params => {
:ids => [3],
:copy => '1',
:issue => {
:project_id => ''
}
}
)
end
end
end
end
def test_bulk_copy_should_add_relations_with_copied_issues
@request.session[:user_id] = 2
assert_difference 'Issue.count', 2 do