Feature #36197 » 36197-v2.patch
| app/controllers/issues_controller.rb | ||
|---|---|---|
| 328 | 328 |
@versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
|
| 329 | 329 |
@categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
|
| 330 | 330 |
if @copy |
| 331 |
@attachments_present = @issues.detect {|i| i.attachments.any?}.present?
|
|
| 331 |
@attachments_present = @issues.detect {|i| i.attachments.any?}.present? &&
|
|
| 332 |
(Setting.copy_attachments_on_issue_copy == 'ask') |
|
| 332 | 333 |
@subtasks_present = @issues.detect {|i| !i.leaf?}.present?
|
| 333 | 334 |
@watchers_present = User.current.allowed_to?(:add_issue_watchers, @projects) && |
| 334 | 335 |
Watcher.where(:watchable_type => 'Issue', |
| ... | ... | |
| 347 | 348 | |
| 348 | 349 |
attributes = parse_params_for_bulk_update(params[:issue]) |
| 349 | 350 |
copy_subtasks = (params[:copy_subtasks] == '1') |
| 350 |
copy_attachments = (params[:copy_attachments] == '1') |
|
| 351 | 351 |
copy_watchers = (params[:copy_watchers] == '1') |
| 352 | 352 | |
| 353 | 353 |
if @copy |
| ... | ... | |
| 386 | 386 |
if @copy |
| 387 | 387 |
issue = orig_issue.copy( |
| 388 | 388 |
{},
|
| 389 |
:attachments => copy_attachments, |
|
| 389 |
:attachments => copy_attachments?(params[:copy_attachments]),
|
|
| 390 | 390 |
:subtasks => copy_subtasks, |
| 391 | 391 |
:watchers => copy_watchers, |
| 392 | 392 |
:link => link_copy?(params[:link_copy]) |
| ... | ... | |
| 593 | 593 |
end |
| 594 | 594 | |
| 595 | 595 |
@link_copy = link_copy?(params[:link_copy]) || request.get? |
| 596 |
@copy_attachments = params[:copy_attachments].present? || request.get?
|
|
| 596 |
@copy_attachments = copy_attachments?(params[:copy_attachments]) || request.get?
|
|
| 597 | 597 |
@copy_subtasks = params[:copy_subtasks].present? || request.get? |
| 598 | 598 |
@copy_watchers = User.current.allowed_to?(:add_issue_watchers, @project) |
| 599 | 599 |
@issue.copy_from(@copy_from, :attachments => @copy_attachments, |
| ... | ... | |
| 696 | 696 |
end |
| 697 | 697 |
end |
| 698 | 698 | |
| 699 |
# Returns true if the attachments should be copied |
|
| 700 |
# from the original issue |
|
| 701 |
def copy_attachments?(param) |
|
| 702 |
case Setting.copy_attachments_on_issue_copy |
|
| 703 |
when 'yes' |
|
| 704 |
true |
|
| 705 |
when 'no' |
|
| 706 |
false |
|
| 707 |
when 'ask' |
|
| 708 |
param == '1' |
|
| 709 |
end |
|
| 710 |
end |
|
| 711 | ||
| 699 | 712 |
# Redirects user after a successful issue creation |
| 700 | 713 |
def redirect_after_create |
| 701 | 714 |
if params[:continue] |
| app/helpers/settings_helper.rb | ||
|---|---|---|
| 166 | 166 |
options.map {|label, value| [l(label), value.to_s]}
|
| 167 | 167 |
end |
| 168 | 168 | |
| 169 |
def copy_attachments_on_issue_copy_options |
|
| 170 |
options = [ |
|
| 171 |
[:general_text_Yes, 'yes'], |
|
| 172 |
[:general_text_No, 'no'], |
|
| 173 |
[:label_ask, 'ask'] |
|
| 174 |
] |
|
| 175 | ||
| 176 |
options.map {|label, value| [l(label), value.to_s]}
|
|
| 177 |
end |
|
| 178 | ||
| 169 | 179 |
def default_global_issue_query_options |
| 170 | 180 |
[[l(:label_none), '']] + IssueQuery.only_public.where(project_id: nil).pluck(:name, :id) |
| 171 | 181 |
end |
| app/views/issues/new.html.erb | ||
|---|---|---|
| 17 | 17 |
<%= check_box_tag 'link_copy', '1', @link_copy %> |
| 18 | 18 |
</p> |
| 19 | 19 |
<% end %> |
| 20 |
<% if @copy_from && @copy_from.attachments.any? %> |
|
| 20 |
<% if @copy_from && Setting.copy_attachments_on_issue_copy == 'ask' && @copy_from.attachments.any? %>
|
|
| 21 | 21 |
<p> |
| 22 | 22 |
<label for="copy_attachments"><%= l(:label_copy_attachments) %></label> |
| 23 | 23 |
<%= check_box_tag 'copy_attachments', '1', @copy_attachments %> |
| app/views/settings/_issues.html.erb | ||
|---|---|---|
| 5 | 5 | |
| 6 | 6 |
<p><%= setting_select :link_copied_issue, link_copied_issue_options %></p> |
| 7 | 7 | |
| 8 |
<p><%= setting_select :copy_attachments_on_issue_copy, copy_attachments_on_issue_copy_options %></p> |
|
| 9 | ||
| 8 | 10 |
<p><%= setting_select :cross_project_subtasks, cross_project_subtasks_options %></p> |
| 9 | 11 | |
| 10 | 12 |
<p><%= setting_check_box :close_duplicate_issues %></p> |
| config/locales/en.yml | ||
|---|---|---|
| 503 | 503 |
setting_force_default_language_for_anonymous: Force default language for anonymous users |
| 504 | 504 |
setting_force_default_language_for_loggedin: Force default language for logged-in users |
| 505 | 505 |
setting_link_copied_issue: Link issues on copy |
| 506 |
setting_copy_attachments_on_issue_copy: Copy attachments on copy |
|
| 506 | 507 |
setting_max_additional_emails: Maximum number of additional email addresses |
| 507 | 508 |
setting_email_domains_allowed: Allowed email domains |
| 508 | 509 |
setting_email_domains_denied: Disallowed email domains |
| config/settings.yml | ||
|---|---|---|
| 190 | 190 |
default: 'derived' |
| 191 | 191 |
link_copied_issue: |
| 192 | 192 |
default: 'ask' |
| 193 |
copy_attachments_on_issue_copy: |
|
| 194 |
default: 'ask' |
|
| 193 | 195 |
close_duplicate_issues: |
| 194 | 196 |
default: 1 |
| 195 | 197 |
issue_group_assignment: |
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 5613 | 5613 |
end |
| 5614 | 5614 |
end |
| 5615 | 5615 | |
| 5616 |
def test_create_as_copy_should_always_copy_attachments_by_settings |
|
| 5617 |
assert_equal 4, Issue.find(3).attachments.size |
|
| 5618 |
with_settings :copy_attachments_on_issue_copy => 'yes' do |
|
| 5619 |
@request.session[:user_id] = 2 |
|
| 5620 |
assert_difference 'Issue.count' do |
|
| 5621 |
assert_difference 'Attachment.count', 4 do |
|
| 5622 |
post( |
|
| 5623 |
:create, |
|
| 5624 |
:params => {
|
|
| 5625 |
:project_id => 1, |
|
| 5626 |
:copy_from => 3, |
|
| 5627 |
:issue => {
|
|
| 5628 |
:subject => 'Copy' |
|
| 5629 |
} |
|
| 5630 |
} |
|
| 5631 |
) |
|
| 5632 |
end |
|
| 5633 |
end |
|
| 5634 |
end |
|
| 5635 |
end |
|
| 5636 | ||
| 5637 |
def test_create_as_copy_should_never_copy_attachments_by_settings |
|
| 5638 |
with_settings :copy_attachments_on_issue_copy => 'no' do |
|
| 5639 |
@request.session[:user_id] = 2 |
|
| 5640 |
assert_difference 'Issue.count' do |
|
| 5641 |
assert_no_difference 'Attachment.count' do |
|
| 5642 |
post( |
|
| 5643 |
:create, |
|
| 5644 |
:params => {
|
|
| 5645 |
:project_id => 1, |
|
| 5646 |
:copy_from => 3, |
|
| 5647 |
:issue => {
|
|
| 5648 |
:subject => 'Copy' |
|
| 5649 |
} |
|
| 5650 |
} |
|
| 5651 |
) |
|
| 5652 |
end |
|
| 5653 |
end |
|
| 5654 |
end |
|
| 5655 |
end |
|
| 5656 | ||
| 5616 | 5657 |
def test_create_as_copy_should_copy_subtasks |
| 5617 | 5658 |
@request.session[:user_id] = 2 |
| 5618 | 5659 |
issue = Issue.generate_with_descendants! |
| ... | ... | |
| 8074 | 8115 |
end |
| 8075 | 8116 |
end |
| 8076 | 8117 | |
| 8118 |
def test_bulk_copy_should_never_copy_attachments_by_settings |
|
| 8119 |
with_settings :copy_attachments_on_issue_copy => 'no' do |
|
| 8120 |
@request.session[:user_id] = 2 |
|
| 8121 |
assert_difference 'Issue.count' do |
|
| 8122 |
assert_no_difference 'Attachment.count' do |
|
| 8123 |
post( |
|
| 8124 |
:bulk_update, |
|
| 8125 |
:params => {
|
|
| 8126 |
:ids => [3], |
|
| 8127 |
:copy => '1', |
|
| 8128 |
:issue => {
|
|
| 8129 |
:project_id => '' |
|
| 8130 |
} |
|
| 8131 |
} |
|
| 8132 |
) |
|
| 8133 |
end |
|
| 8134 |
end |
|
| 8135 |
end |
|
| 8136 |
end |
|
| 8137 | ||
| 8138 |
def test_bulk_copy_should_always_copy_attachments_by_settings |
|
| 8139 |
assert_equal 4, Issue.find(3).attachments.size |
|
| 8140 |
with_settings :copy_attachments_on_issue_copy => 'yes' do |
|
| 8141 |
@request.session[:user_id] = 2 |
|
| 8142 |
assert_difference 'Issue.count' do |
|
| 8143 |
assert_difference 'Attachment.count', 4 do |
|
| 8144 |
post( |
|
| 8145 |
:bulk_update, |
|
| 8146 |
:params => {
|
|
| 8147 |
:ids => [3], |
|
| 8148 |
:copy => '1', |
|
| 8149 |
:issue => {
|
|
| 8150 |
:project_id => '' |
|
| 8151 |
} |
|
| 8152 |
} |
|
| 8153 |
) |
|
| 8154 |
end |
|
| 8155 |
end |
|
| 8156 |
end |
|
| 8157 |
end |
|
| 8158 | ||
| 8077 | 8159 |
def test_bulk_copy_should_add_relations_with_copied_issues |
| 8078 | 8160 |
@request.session[:user_id] = 2 |
| 8079 | 8161 |
assert_difference 'Issue.count', 2 do |
- « Previous
- 1
- 2
- 3
- Next »