mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 17:26:06 +01:00
Configurable behavour for linking issues on copy (#18500).
git-svn-id: http://svn.redmine.org/redmine/trunk@13668 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -273,7 +273,8 @@ class IssuesController < ApplicationController
|
||||
if @copy
|
||||
issue = orig_issue.copy({},
|
||||
:attachments => params[:copy_attachments].present?,
|
||||
:subtasks => params[:copy_subtasks].present?
|
||||
:subtasks => params[:copy_subtasks].present?,
|
||||
:link => link_copy?(params[:link_copy])
|
||||
)
|
||||
else
|
||||
issue = orig_issue
|
||||
@@ -410,9 +411,10 @@ class IssuesController < ApplicationController
|
||||
if params[:copy_from]
|
||||
begin
|
||||
@copy_from = Issue.visible.find(params[:copy_from])
|
||||
@link_copy = link_copy?(params[:link_copy]) || request.get?
|
||||
@copy_attachments = params[:copy_attachments].present? || request.get?
|
||||
@copy_subtasks = params[:copy_subtasks].present? || request.get?
|
||||
@issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks)
|
||||
@issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
return
|
||||
@@ -486,4 +488,15 @@ class IssuesController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def link_copy?(param)
|
||||
case Setting.link_copied_issue
|
||||
when 'yes'
|
||||
true
|
||||
when 'no'
|
||||
false
|
||||
when 'ask'
|
||||
param == '1'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,6 +104,16 @@ module SettingsHelper
|
||||
content_tag(:label, tag + text, options)
|
||||
end
|
||||
|
||||
def link_copied_issue_options
|
||||
options = [
|
||||
[:general_text_Yes, 'yes'],
|
||||
[:general_text_No, 'no'],
|
||||
[:label_ask, 'ask']
|
||||
]
|
||||
|
||||
options.map {|label, value| [l(label), value.to_s]}
|
||||
end
|
||||
|
||||
def cross_project_subtasks_options
|
||||
options = [
|
||||
[:label_disabled, ''],
|
||||
|
||||
@@ -97,6 +97,14 @@
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if @copy && Setting.link_copied_issue == 'ask' %>
|
||||
<p>
|
||||
<label for='link_copy'><%= l(:label_link_copied_issue) %></label>
|
||||
<%= hidden_field_tag 'link_copy', '0' %>
|
||||
<%= check_box_tag 'link_copy', '1', params[:link_copy] != 0 %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if @copy && @attachments_present %>
|
||||
<%= hidden_field_tag 'copy_attachments', '0' %>
|
||||
<p>
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
<%= render :partial => 'issues/form', :locals => {:f => f} %>
|
||||
</div>
|
||||
|
||||
<% if @copy_from && Setting.link_copied_issue == 'ask' %>
|
||||
<p>
|
||||
<label for="link_copy"><%= l(:label_link_copied_issue) %></label>
|
||||
<%= check_box_tag 'link_copy', '1', @link_copy %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if @copy_from && @copy_from.attachments.any? %>
|
||||
<p>
|
||||
<label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<div class="box tabular settings">
|
||||
<p><%= setting_check_box :cross_project_issue_relations %></p>
|
||||
|
||||
<p><%= setting_select :link_copied_issue, link_copied_issue_options %></p>
|
||||
|
||||
<p><%= setting_select :cross_project_subtasks, cross_project_subtasks_options %></p>
|
||||
|
||||
<p><%= setting_check_box :issue_group_assignment %></p>
|
||||
|
||||
@@ -412,6 +412,7 @@ en:
|
||||
setting_mail_handler_excluded_filenames: Exclude attachments by name
|
||||
setting_force_default_language_for_anonymous: Force default language for anonymous users
|
||||
setting_force_default_language_for_loggedin: Force default language for logged-in users
|
||||
setting_link_copied_issue: Link issues on copy
|
||||
|
||||
permission_add_project: Create project
|
||||
permission_add_subprojects: Create subprojects
|
||||
@@ -924,6 +925,8 @@ en:
|
||||
label_users_visibility_all: All active users
|
||||
label_users_visibility_members_of_visible_projects: Members of visible projects
|
||||
label_edit_attachments: Edit attached files
|
||||
label_link_copied_issue: Link copied issue
|
||||
label_ask: Ask
|
||||
|
||||
button_login: Login
|
||||
button_submit: Submit
|
||||
|
||||
@@ -432,6 +432,7 @@ fr:
|
||||
setting_mail_handler_excluded_filenames: Exclure les fichiers attachés par leur nom
|
||||
setting_force_default_language_for_anonymous: Forcer la langue par défault pour les utilisateurs anonymes
|
||||
setting_force_default_language_for_loggedin: Forcer la langue par défault pour les utilisateurs identifiés
|
||||
setting_link_copied_issue: Lier les demandes lors de la copie
|
||||
|
||||
permission_add_project: Créer un projet
|
||||
permission_add_subprojects: Créer des sous-projets
|
||||
@@ -944,6 +945,8 @@ fr:
|
||||
label_users_visibility_all: Tous les utilisateurs actifs
|
||||
label_users_visibility_members_of_visible_projects: Membres des projets visibles
|
||||
label_edit_attachments: Modifier les fichiers attachés
|
||||
label_link_copied_issue: Lier la demande copiée
|
||||
label_ask: Demander
|
||||
|
||||
button_login: Connexion
|
||||
button_submit: Soumettre
|
||||
|
||||
@@ -136,6 +136,8 @@ cross_project_issue_relations:
|
||||
# Enables subtasks to be in other projects
|
||||
cross_project_subtasks:
|
||||
default: 'tree'
|
||||
link_copied_issue:
|
||||
default: 'ask'
|
||||
issue_group_assignment:
|
||||
default: 0
|
||||
default_issue_start_date_to_creation_date:
|
||||
|
||||
@@ -2540,14 +2540,12 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert count > 0
|
||||
assert_difference 'Issue.count' do
|
||||
assert_difference 'Attachment.count', count do
|
||||
assert_difference 'Journal.count', 2 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'
|
||||
end
|
||||
end
|
||||
end
|
||||
copy = Issue.order('id DESC').first
|
||||
assert_equal count, copy.attachments.count
|
||||
assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort
|
||||
@@ -2560,25 +2558,22 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert count > 0
|
||||
assert_difference 'Issue.count' do
|
||||
assert_no_difference 'Attachment.count' do
|
||||
assert_difference 'Journal.count', 2 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.order('id DESC').first
|
||||
assert_equal 0, copy.attachments.count
|
||||
end
|
||||
|
||||
def test_create_as_copy_with_attachments_should_add_new_files
|
||||
def test_create_as_copy_with_attachments_should_also_add_new_files
|
||||
@request.session[:user_id] = 2
|
||||
issue = Issue.find(3)
|
||||
count = issue.attachments.count
|
||||
assert count > 0
|
||||
assert_difference 'Issue.count' do
|
||||
assert_difference 'Attachment.count', count + 1 do
|
||||
assert_difference 'Journal.count', 2 do
|
||||
post :create, :project_id => 1, :copy_from => 3,
|
||||
:issue => {:project_id => '1', :tracker_id => '3',
|
||||
:status_id => '1', :subject => 'Copy with attachments'},
|
||||
@@ -2588,7 +2583,6 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
'description' => 'test file'}}
|
||||
end
|
||||
end
|
||||
end
|
||||
copy = Issue.order('id DESC').first
|
||||
assert_equal count + 1, copy.attachments.count
|
||||
end
|
||||
@@ -2597,7 +2591,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Issue.count' do
|
||||
assert_difference 'IssueRelation.count' do
|
||||
post :create, :project_id => 1, :copy_from => 1,
|
||||
post :create, :project_id => 1, :copy_from => 1, :link_copy => '1',
|
||||
:issue => {:project_id => '1', :tracker_id => '3',
|
||||
:status_id => '1', :subject => 'Copy'}
|
||||
end
|
||||
@@ -2606,18 +2600,38 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_equal 1, copy.relations.size
|
||||
end
|
||||
|
||||
def test_create_as_copy_should_allow_not_to_add_relation_with_copied_issue
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Issue.count' do
|
||||
assert_no_difference 'IssueRelation.count' do
|
||||
post :create, :project_id => 1, :copy_from => 1,
|
||||
:issue => {:subject => 'Copy'}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_create_as_copy_should_always_add_relation_with_copied_issue_by_setting
|
||||
with_settings :link_copied_issue => 'yes' do
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Issue.count' do
|
||||
assert_difference 'IssueRelation.count' do
|
||||
post :create, :project_id => 1, :copy_from => 1,
|
||||
: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!
|
||||
count = issue.descendants.count
|
||||
assert_difference 'Issue.count', count + 1 do
|
||||
assert_difference 'Journal.count', (count + 1) * 2 do
|
||||
post :create, :project_id => 1, :copy_from => issue.id,
|
||||
:issue => {:project_id => '1', :tracker_id => '3',
|
||||
:status_id => '1', :subject => 'Copy with subtasks'},
|
||||
:copy_subtasks => '1'
|
||||
end
|
||||
end
|
||||
copy = Issue.where(:parent_id => nil).order('id DESC').first
|
||||
assert_equal count, copy.descendants.count
|
||||
assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort
|
||||
@@ -2627,12 +2641,10 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
@request.session[:user_id] = 2
|
||||
issue = Issue.generate_with_descendants!
|
||||
assert_difference 'Issue.count', 1 do
|
||||
assert_difference 'Journal.count', 2 do
|
||||
post :create, :project_id => 1, :copy_from => 3,
|
||||
:issue => {:project_id => '1', :tracker_id => '3',
|
||||
:status_id => '1', :subject => 'Copy with subtasks'}
|
||||
end
|
||||
end
|
||||
copy = Issue.where(:parent_id => nil).order('id DESC').first
|
||||
assert_equal 0, copy.descendants.count
|
||||
end
|
||||
@@ -3840,7 +3852,6 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
issue = Issue.order('id DESC').first
|
||||
assert_equal 1, issue.journals.size
|
||||
journal = issue.journals.first
|
||||
assert_equal 1, journal.details.size
|
||||
assert_equal 'Copying one issue', journal.notes
|
||||
end
|
||||
|
||||
@@ -3879,7 +3890,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
assert_difference 'Issue.count', 2 do
|
||||
assert_difference 'IssueRelation.count', 2 do
|
||||
post :bulk_update, :ids => [1, 3], :copy => '1',
|
||||
post :bulk_update, :ids => [1, 3], :copy => '1', :link_copy => '1',
|
||||
:issue => {
|
||||
:project_id => '1'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user