##// END OF EJS Templates
Configurable behavour for linking issues on copy (#18500)....
Jean-Philippe Lang -
r13286:30d65829b859
parent child
Show More
@@ -273,7 +273,8 class IssuesController < ApplicationController
273 273 if @copy
274 274 issue = orig_issue.copy({},
275 275 :attachments => params[:copy_attachments].present?,
276 :subtasks => params[:copy_subtasks].present?
276 :subtasks => params[:copy_subtasks].present?,
277 :link => link_copy?(params[:link_copy])
277 278 )
278 279 else
279 280 issue = orig_issue
@@ -410,9 +411,10 class IssuesController < ApplicationController
410 411 if params[:copy_from]
411 412 begin
412 413 @copy_from = Issue.visible.find(params[:copy_from])
414 @link_copy = link_copy?(params[:link_copy]) || request.get?
413 415 @copy_attachments = params[:copy_attachments].present? || request.get?
414 416 @copy_subtasks = params[:copy_subtasks].present? || request.get?
415 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks)
417 @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
416 418 rescue ActiveRecord::RecordNotFound
417 419 render_404
418 420 return
@@ -486,4 +488,15 class IssuesController < ApplicationController
486 488 end
487 489 end
488 490 end
491
492 def link_copy?(param)
493 case Setting.link_copied_issue
494 when 'yes'
495 true
496 when 'no'
497 false
498 when 'ask'
499 param == '1'
500 end
501 end
489 502 end
@@ -104,6 +104,16 module SettingsHelper
104 104 content_tag(:label, tag + text, options)
105 105 end
106 106
107 def link_copied_issue_options
108 options = [
109 [:general_text_Yes, 'yes'],
110 [:general_text_No, 'no'],
111 [:label_ask, 'ask']
112 ]
113
114 options.map {|label, value| [l(label), value.to_s]}
115 end
116
107 117 def cross_project_subtasks_options
108 118 options = [
109 119 [:label_disabled, ''],
@@ -97,6 +97,14
97 97 </p>
98 98 <% end %>
99 99
100 <% if @copy && Setting.link_copied_issue == 'ask' %>
101 <p>
102 <label for='link_copy'><%= l(:label_link_copied_issue) %></label>
103 <%= hidden_field_tag 'link_copy', '0' %>
104 <%= check_box_tag 'link_copy', '1', params[:link_copy] != 0 %>
105 </p>
106 <% end %>
107
100 108 <% if @copy && @attachments_present %>
101 109 <%= hidden_field_tag 'copy_attachments', '0' %>
102 110 <p>
@@ -11,6 +11,12
11 11 <%= render :partial => 'issues/form', :locals => {:f => f} %>
12 12 </div>
13 13
14 <% if @copy_from && Setting.link_copied_issue == 'ask' %>
15 <p>
16 <label for="link_copy"><%= l(:label_link_copied_issue) %></label>
17 <%= check_box_tag 'link_copy', '1', @link_copy %>
18 </p>
19 <% end %>
14 20 <% if @copy_from && @copy_from.attachments.any? %>
15 21 <p>
16 22 <label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
@@ -3,6 +3,8
3 3 <div class="box tabular settings">
4 4 <p><%= setting_check_box :cross_project_issue_relations %></p>
5 5
6 <p><%= setting_select :link_copied_issue, link_copied_issue_options %></p>
7
6 8 <p><%= setting_select :cross_project_subtasks, cross_project_subtasks_options %></p>
7 9
8 10 <p><%= setting_check_box :issue_group_assignment %></p>
@@ -412,6 +412,7 en:
412 412 setting_mail_handler_excluded_filenames: Exclude attachments by name
413 413 setting_force_default_language_for_anonymous: Force default language for anonymous users
414 414 setting_force_default_language_for_loggedin: Force default language for logged-in users
415 setting_link_copied_issue: Link issues on copy
415 416
416 417 permission_add_project: Create project
417 418 permission_add_subprojects: Create subprojects
@@ -924,6 +925,8 en:
924 925 label_users_visibility_all: All active users
925 926 label_users_visibility_members_of_visible_projects: Members of visible projects
926 927 label_edit_attachments: Edit attached files
928 label_link_copied_issue: Link copied issue
929 label_ask: Ask
927 930
928 931 button_login: Login
929 932 button_submit: Submit
@@ -432,6 +432,7 fr:
432 432 setting_mail_handler_excluded_filenames: Exclure les fichiers attachΓ©s par leur nom
433 433 setting_force_default_language_for_anonymous: Forcer la langue par dΓ©fault pour les utilisateurs anonymes
434 434 setting_force_default_language_for_loggedin: Forcer la langue par dΓ©fault pour les utilisateurs identifiΓ©s
435 setting_link_copied_issue: Lier les demandes lors de la copie
435 436
436 437 permission_add_project: CrΓ©er un projet
437 438 permission_add_subprojects: CrΓ©er des sous-projets
@@ -944,6 +945,8 fr:
944 945 label_users_visibility_all: Tous les utilisateurs actifs
945 946 label_users_visibility_members_of_visible_projects: Membres des projets visibles
946 947 label_edit_attachments: Modifier les fichiers attachΓ©s
948 label_link_copied_issue: Lier la demande copiΓ©e
949 label_ask: Demander
947 950
948 951 button_login: Connexion
949 952 button_submit: Soumettre
@@ -136,6 +136,8 cross_project_issue_relations:
136 136 # Enables subtasks to be in other projects
137 137 cross_project_subtasks:
138 138 default: 'tree'
139 link_copied_issue:
140 default: 'ask'
139 141 issue_group_assignment:
140 142 default: 0
141 143 default_issue_start_date_to_creation_date:
@@ -2540,12 +2540,10 class IssuesControllerTest < ActionController::TestCase
2540 2540 assert count > 0
2541 2541 assert_difference 'Issue.count' do
2542 2542 assert_difference 'Attachment.count', count do
2543 assert_difference 'Journal.count', 2 do
2544 post :create, :project_id => 1, :copy_from => 3,
2545 :issue => {:project_id => '1', :tracker_id => '3',
2546 :status_id => '1', :subject => 'Copy with attachments'},
2547 :copy_attachments => '1'
2548 end
2543 post :create, :project_id => 1, :copy_from => 3,
2544 :issue => {:project_id => '1', :tracker_id => '3',
2545 :status_id => '1', :subject => 'Copy with attachments'},
2546 :copy_attachments => '1'
2549 2547 end
2550 2548 end
2551 2549 copy = Issue.order('id DESC').first
@@ -2560,33 +2558,29 class IssuesControllerTest < ActionController::TestCase
2560 2558 assert count > 0
2561 2559 assert_difference 'Issue.count' do
2562 2560 assert_no_difference 'Attachment.count' do
2563 assert_difference 'Journal.count', 2 do
2564 post :create, :project_id => 1, :copy_from => 3,
2565 :issue => {:project_id => '1', :tracker_id => '3',
2566 :status_id => '1', :subject => 'Copy with attachments'}
2567 end
2561 post :create, :project_id => 1, :copy_from => 3,
2562 :issue => {:project_id => '1', :tracker_id => '3',
2563 :status_id => '1', :subject => 'Copy with attachments'}
2568 2564 end
2569 2565 end
2570 2566 copy = Issue.order('id DESC').first
2571 2567 assert_equal 0, copy.attachments.count
2572 2568 end
2573 2569
2574 def test_create_as_copy_with_attachments_should_add_new_files
2570 def test_create_as_copy_with_attachments_should_also_add_new_files
2575 2571 @request.session[:user_id] = 2
2576 2572 issue = Issue.find(3)
2577 2573 count = issue.attachments.count
2578 2574 assert count > 0
2579 2575 assert_difference 'Issue.count' do
2580 2576 assert_difference 'Attachment.count', count + 1 do
2581 assert_difference 'Journal.count', 2 do
2582 post :create, :project_id => 1, :copy_from => 3,
2583 :issue => {:project_id => '1', :tracker_id => '3',
2584 :status_id => '1', :subject => 'Copy with attachments'},
2585 :copy_attachments => '1',
2586 :attachments => {'1' =>
2587 {'file' => uploaded_test_file('testfile.txt', 'text/plain'),
2588 'description' => 'test file'}}
2589 end
2577 post :create, :project_id => 1, :copy_from => 3,
2578 :issue => {:project_id => '1', :tracker_id => '3',
2579 :status_id => '1', :subject => 'Copy with attachments'},
2580 :copy_attachments => '1',
2581 :attachments => {'1' =>
2582 {'file' => uploaded_test_file('testfile.txt', 'text/plain'),
2583 'description' => 'test file'}}
2590 2584 end
2591 2585 end
2592 2586 copy = Issue.order('id DESC').first
@@ -2597,7 +2591,7 class IssuesControllerTest < ActionController::TestCase
2597 2591 @request.session[:user_id] = 2
2598 2592 assert_difference 'Issue.count' do
2599 2593 assert_difference 'IssueRelation.count' do
2600 post :create, :project_id => 1, :copy_from => 1,
2594 post :create, :project_id => 1, :copy_from => 1, :link_copy => '1',
2601 2595 :issue => {:project_id => '1', :tracker_id => '3',
2602 2596 :status_id => '1', :subject => 'Copy'}
2603 2597 end
@@ -2606,17 +2600,37 class IssuesControllerTest < ActionController::TestCase
2606 2600 assert_equal 1, copy.relations.size
2607 2601 end
2608 2602
2603 def test_create_as_copy_should_allow_not_to_add_relation_with_copied_issue
2604 @request.session[:user_id] = 2
2605 assert_difference 'Issue.count' do
2606 assert_no_difference 'IssueRelation.count' do
2607 post :create, :project_id => 1, :copy_from => 1,
2608 :issue => {:subject => 'Copy'}
2609 end
2610 end
2611 end
2612
2613 def test_create_as_copy_should_always_add_relation_with_copied_issue_by_setting
2614 with_settings :link_copied_issue => 'yes' do
2615 @request.session[:user_id] = 2
2616 assert_difference 'Issue.count' do
2617 assert_difference 'IssueRelation.count' do
2618 post :create, :project_id => 1, :copy_from => 1,
2619 :issue => {:subject => 'Copy'}
2620 end
2621 end
2622 end
2623 end
2624
2609 2625 def test_create_as_copy_should_copy_subtasks
2610 2626 @request.session[:user_id] = 2
2611 2627 issue = Issue.generate_with_descendants!
2612 2628 count = issue.descendants.count
2613 2629 assert_difference 'Issue.count', count + 1 do
2614 assert_difference 'Journal.count', (count + 1) * 2 do
2615 post :create, :project_id => 1, :copy_from => issue.id,
2616 :issue => {:project_id => '1', :tracker_id => '3',
2617 :status_id => '1', :subject => 'Copy with subtasks'},
2618 :copy_subtasks => '1'
2619 end
2630 post :create, :project_id => 1, :copy_from => issue.id,
2631 :issue => {:project_id => '1', :tracker_id => '3',
2632 :status_id => '1', :subject => 'Copy with subtasks'},
2633 :copy_subtasks => '1'
2620 2634 end
2621 2635 copy = Issue.where(:parent_id => nil).order('id DESC').first
2622 2636 assert_equal count, copy.descendants.count
@@ -2627,11 +2641,9 class IssuesControllerTest < ActionController::TestCase
2627 2641 @request.session[:user_id] = 2
2628 2642 issue = Issue.generate_with_descendants!
2629 2643 assert_difference 'Issue.count', 1 do
2630 assert_difference 'Journal.count', 2 do
2631 post :create, :project_id => 1, :copy_from => 3,
2632 :issue => {:project_id => '1', :tracker_id => '3',
2633 :status_id => '1', :subject => 'Copy with subtasks'}
2634 end
2644 post :create, :project_id => 1, :copy_from => 3,
2645 :issue => {:project_id => '1', :tracker_id => '3',
2646 :status_id => '1', :subject => 'Copy with subtasks'}
2635 2647 end
2636 2648 copy = Issue.where(:parent_id => nil).order('id DESC').first
2637 2649 assert_equal 0, copy.descendants.count
@@ -3840,7 +3852,6 class IssuesControllerTest < ActionController::TestCase
3840 3852 issue = Issue.order('id DESC').first
3841 3853 assert_equal 1, issue.journals.size
3842 3854 journal = issue.journals.first
3843 assert_equal 1, journal.details.size
3844 3855 assert_equal 'Copying one issue', journal.notes
3845 3856 end
3846 3857
@@ -3879,7 +3890,7 class IssuesControllerTest < ActionController::TestCase
3879 3890
3880 3891 assert_difference 'Issue.count', 2 do
3881 3892 assert_difference 'IssueRelation.count', 2 do
3882 post :bulk_update, :ids => [1, 3], :copy => '1',
3893 post :bulk_update, :ids => [1, 3], :copy => '1', :link_copy => '1',
3883 3894 :issue => {
3884 3895 :project_id => '1'
3885 3896 }
General Comments 0
You need to be logged in to leave comments. Login now