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