mirror of
https://github.com/redmine/redmine.git
synced 2025-11-17 18:50:53 +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
|
if @copy
|
||||||
issue = orig_issue.copy({},
|
issue = orig_issue.copy({},
|
||||||
:attachments => params[:copy_attachments].present?,
|
:attachments => params[:copy_attachments].present?,
|
||||||
:subtasks => params[:copy_subtasks].present?
|
:subtasks => params[:copy_subtasks].present?,
|
||||||
|
:link => link_copy?(params[:link_copy])
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
issue = orig_issue
|
issue = orig_issue
|
||||||
@@ -410,9 +411,10 @@ class IssuesController < ApplicationController
|
|||||||
if params[:copy_from]
|
if params[:copy_from]
|
||||||
begin
|
begin
|
||||||
@copy_from = Issue.visible.find(params[:copy_from])
|
@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_attachments = params[:copy_attachments].present? || request.get?
|
||||||
@copy_subtasks = params[:copy_subtasks].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
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
return
|
return
|
||||||
@@ -486,4 +488,15 @@ class IssuesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -104,6 +104,16 @@ module SettingsHelper
|
|||||||
content_tag(:label, tag + text, options)
|
content_tag(:label, tag + text, options)
|
||||||
end
|
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
|
def cross_project_subtasks_options
|
||||||
options = [
|
options = [
|
||||||
[:label_disabled, ''],
|
[:label_disabled, ''],
|
||||||
|
|||||||
@@ -97,6 +97,14 @@
|
|||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% 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 %>
|
<% if @copy && @attachments_present %>
|
||||||
<%= hidden_field_tag 'copy_attachments', '0' %>
|
<%= hidden_field_tag 'copy_attachments', '0' %>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -11,6 +11,12 @@
|
|||||||
<%= render :partial => 'issues/form', :locals => {:f => f} %>
|
<%= render :partial => 'issues/form', :locals => {:f => f} %>
|
||||||
</div>
|
</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? %>
|
<% if @copy_from && @copy_from.attachments.any? %>
|
||||||
<p>
|
<p>
|
||||||
<label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
|
<label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
<div class="box tabular settings">
|
<div class="box tabular settings">
|
||||||
<p><%= setting_check_box :cross_project_issue_relations %></p>
|
<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_select :cross_project_subtasks, cross_project_subtasks_options %></p>
|
||||||
|
|
||||||
<p><%= setting_check_box :issue_group_assignment %></p>
|
<p><%= setting_check_box :issue_group_assignment %></p>
|
||||||
|
|||||||
@@ -412,6 +412,7 @@ en:
|
|||||||
setting_mail_handler_excluded_filenames: Exclude attachments by name
|
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_anonymous: Force default language for anonymous users
|
||||||
setting_force_default_language_for_loggedin: Force default language for logged-in 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_project: Create project
|
||||||
permission_add_subprojects: Create subprojects
|
permission_add_subprojects: Create subprojects
|
||||||
@@ -924,6 +925,8 @@ en:
|
|||||||
label_users_visibility_all: All active users
|
label_users_visibility_all: All active users
|
||||||
label_users_visibility_members_of_visible_projects: Members of visible projects
|
label_users_visibility_members_of_visible_projects: Members of visible projects
|
||||||
label_edit_attachments: Edit attached files
|
label_edit_attachments: Edit attached files
|
||||||
|
label_link_copied_issue: Link copied issue
|
||||||
|
label_ask: Ask
|
||||||
|
|
||||||
button_login: Login
|
button_login: Login
|
||||||
button_submit: Submit
|
button_submit: Submit
|
||||||
|
|||||||
@@ -432,6 +432,7 @@ fr:
|
|||||||
setting_mail_handler_excluded_filenames: Exclure les fichiers attachés par leur nom
|
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_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_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_project: Créer un projet
|
||||||
permission_add_subprojects: Créer des sous-projets
|
permission_add_subprojects: Créer des sous-projets
|
||||||
@@ -944,6 +945,8 @@ fr:
|
|||||||
label_users_visibility_all: Tous les utilisateurs actifs
|
label_users_visibility_all: Tous les utilisateurs actifs
|
||||||
label_users_visibility_members_of_visible_projects: Membres des projets visibles
|
label_users_visibility_members_of_visible_projects: Membres des projets visibles
|
||||||
label_edit_attachments: Modifier les fichiers attachés
|
label_edit_attachments: Modifier les fichiers attachés
|
||||||
|
label_link_copied_issue: Lier la demande copiée
|
||||||
|
label_ask: Demander
|
||||||
|
|
||||||
button_login: Connexion
|
button_login: Connexion
|
||||||
button_submit: Soumettre
|
button_submit: Soumettre
|
||||||
|
|||||||
@@ -136,6 +136,8 @@ cross_project_issue_relations:
|
|||||||
# Enables subtasks to be in other projects
|
# Enables subtasks to be in other projects
|
||||||
cross_project_subtasks:
|
cross_project_subtasks:
|
||||||
default: 'tree'
|
default: 'tree'
|
||||||
|
link_copied_issue:
|
||||||
|
default: 'ask'
|
||||||
issue_group_assignment:
|
issue_group_assignment:
|
||||||
default: 0
|
default: 0
|
||||||
default_issue_start_date_to_creation_date:
|
default_issue_start_date_to_creation_date:
|
||||||
|
|||||||
@@ -2540,12 +2540,10 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert count > 0
|
assert count > 0
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
assert_difference 'Attachment.count', count do
|
assert_difference 'Attachment.count', count do
|
||||||
assert_difference 'Journal.count', 2 do
|
post :create, :project_id => 1, :copy_from => 3,
|
||||||
post :create, :project_id => 1, :copy_from => 3,
|
:issue => {:project_id => '1', :tracker_id => '3',
|
||||||
:issue => {:project_id => '1', :tracker_id => '3',
|
:status_id => '1', :subject => 'Copy with attachments'},
|
||||||
:status_id => '1', :subject => 'Copy with attachments'},
|
:copy_attachments => '1'
|
||||||
:copy_attachments => '1'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
copy = Issue.order('id DESC').first
|
copy = Issue.order('id DESC').first
|
||||||
@@ -2560,33 +2558,29 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert count > 0
|
assert count > 0
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
assert_no_difference 'Attachment.count' do
|
assert_no_difference 'Attachment.count' do
|
||||||
assert_difference 'Journal.count', 2 do
|
post :create, :project_id => 1, :copy_from => 3,
|
||||||
post :create, :project_id => 1, :copy_from => 3,
|
:issue => {:project_id => '1', :tracker_id => '3',
|
||||||
:issue => {:project_id => '1', :tracker_id => '3',
|
:status_id => '1', :subject => 'Copy with attachments'}
|
||||||
:status_id => '1', :subject => 'Copy with attachments'}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
copy = Issue.order('id DESC').first
|
copy = Issue.order('id DESC').first
|
||||||
assert_equal 0, copy.attachments.count
|
assert_equal 0, copy.attachments.count
|
||||||
end
|
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
|
@request.session[:user_id] = 2
|
||||||
issue = Issue.find(3)
|
issue = Issue.find(3)
|
||||||
count = issue.attachments.count
|
count = issue.attachments.count
|
||||||
assert count > 0
|
assert count > 0
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
assert_difference 'Attachment.count', count + 1 do
|
assert_difference 'Attachment.count', count + 1 do
|
||||||
assert_difference 'Journal.count', 2 do
|
post :create, :project_id => 1, :copy_from => 3,
|
||||||
post :create, :project_id => 1, :copy_from => 3,
|
:issue => {:project_id => '1', :tracker_id => '3',
|
||||||
:issue => {:project_id => '1', :tracker_id => '3',
|
:status_id => '1', :subject => 'Copy with attachments'},
|
||||||
:status_id => '1', :subject => 'Copy with attachments'},
|
:copy_attachments => '1',
|
||||||
:copy_attachments => '1',
|
:attachments => {'1' =>
|
||||||
:attachments => {'1' =>
|
{'file' => uploaded_test_file('testfile.txt', 'text/plain'),
|
||||||
{'file' => uploaded_test_file('testfile.txt', 'text/plain'),
|
'description' => 'test file'}}
|
||||||
'description' => 'test file'}}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
copy = Issue.order('id DESC').first
|
copy = Issue.order('id DESC').first
|
||||||
@@ -2597,7 +2591,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
assert_difference 'Issue.count' do
|
assert_difference 'Issue.count' do
|
||||||
assert_difference 'IssueRelation.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',
|
:issue => {:project_id => '1', :tracker_id => '3',
|
||||||
:status_id => '1', :subject => 'Copy'}
|
:status_id => '1', :subject => 'Copy'}
|
||||||
end
|
end
|
||||||
@@ -2606,17 +2600,37 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal 1, copy.relations.size
|
assert_equal 1, copy.relations.size
|
||||||
end
|
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
|
def test_create_as_copy_should_copy_subtasks
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
issue = Issue.generate_with_descendants!
|
issue = Issue.generate_with_descendants!
|
||||||
count = issue.descendants.count
|
count = issue.descendants.count
|
||||||
assert_difference 'Issue.count', count + 1 do
|
assert_difference 'Issue.count', count + 1 do
|
||||||
assert_difference 'Journal.count', (count + 1) * 2 do
|
post :create, :project_id => 1, :copy_from => issue.id,
|
||||||
post :create, :project_id => 1, :copy_from => issue.id,
|
:issue => {:project_id => '1', :tracker_id => '3',
|
||||||
:issue => {:project_id => '1', :tracker_id => '3',
|
:status_id => '1', :subject => 'Copy with subtasks'},
|
||||||
:status_id => '1', :subject => 'Copy with subtasks'},
|
:copy_subtasks => '1'
|
||||||
:copy_subtasks => '1'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
copy = Issue.where(:parent_id => nil).order('id DESC').first
|
copy = Issue.where(:parent_id => nil).order('id DESC').first
|
||||||
assert_equal count, copy.descendants.count
|
assert_equal count, copy.descendants.count
|
||||||
@@ -2627,11 +2641,9 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
issue = Issue.generate_with_descendants!
|
issue = Issue.generate_with_descendants!
|
||||||
assert_difference 'Issue.count', 1 do
|
assert_difference 'Issue.count', 1 do
|
||||||
assert_difference 'Journal.count', 2 do
|
post :create, :project_id => 1, :copy_from => 3,
|
||||||
post :create, :project_id => 1, :copy_from => 3,
|
:issue => {:project_id => '1', :tracker_id => '3',
|
||||||
:issue => {:project_id => '1', :tracker_id => '3',
|
:status_id => '1', :subject => 'Copy with subtasks'}
|
||||||
:status_id => '1', :subject => 'Copy with subtasks'}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
copy = Issue.where(:parent_id => nil).order('id DESC').first
|
copy = Issue.where(:parent_id => nil).order('id DESC').first
|
||||||
assert_equal 0, copy.descendants.count
|
assert_equal 0, copy.descendants.count
|
||||||
@@ -3840,7 +3852,6 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
issue = Issue.order('id DESC').first
|
issue = Issue.order('id DESC').first
|
||||||
assert_equal 1, issue.journals.size
|
assert_equal 1, issue.journals.size
|
||||||
journal = issue.journals.first
|
journal = issue.journals.first
|
||||||
assert_equal 1, journal.details.size
|
|
||||||
assert_equal 'Copying one issue', journal.notes
|
assert_equal 'Copying one issue', journal.notes
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3879,7 +3890,7 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
assert_difference 'Issue.count', 2 do
|
assert_difference 'Issue.count', 2 do
|
||||||
assert_difference 'IssueRelation.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 => {
|
:issue => {
|
||||||
:project_id => '1'
|
:project_id => '1'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user