diff options
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | app/views/settings/_issues.html.erb | 2 | ||||
-rw-r--r-- | config/locales/en.yml | 1 | ||||
-rw-r--r-- | config/locales/fr.yml | 1 | ||||
-rw-r--r-- | config/settings.yml | 2 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 17 |
6 files changed, 24 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 33e6bf223..f984e0332 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1798,7 +1798,7 @@ class Issue < ActiveRecord::Base # Closes duplicates if the issue is being closed def close_duplicates - if closing? + if Setting.close_duplicate_issues? && closing? duplicates.each do |duplicate| # Reload is needed in case the duplicate was updated by a previous duplicate duplicate.reload diff --git a/app/views/settings/_issues.html.erb b/app/views/settings/_issues.html.erb index f29a6d4ec..17e8ca99b 100644 --- a/app/views/settings/_issues.html.erb +++ b/app/views/settings/_issues.html.erb @@ -7,6 +7,8 @@ <p><%= setting_select :cross_project_subtasks, cross_project_subtasks_options %></p> +<p><%= setting_check_box :close_duplicate_issues %></p> + <p><%= setting_check_box :issue_group_assignment %></p> <p><%= setting_check_box :default_issue_start_date_to_creation_date %></p> diff --git a/config/locales/en.yml b/config/locales/en.yml index df57a57f3..50a003f84 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -462,6 +462,7 @@ en: setting_new_item_menu_tab: Project menu tab for creating new objects setting_commit_logs_formatting: Apply text formatting to commit messages setting_timelog_required_fields: Required fields for time logs + setting_close_duplicate_issues: Close duplicate issues automatically permission_add_project: Create project permission_add_subprojects: Create subprojects diff --git a/config/locales/fr.yml b/config/locales/fr.yml index dea9e3e09..48226cfb0 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -474,6 +474,7 @@ fr: setting_new_item_menu_tab: Onglet de création d'objets dans le menu du project setting_commit_logs_formatting: Appliquer le formattage de texte aux messages de commit setting_timelog_required_fields: Champs obligatoire pour les temps passés + setting_close_duplicate_issues: Fermer les doublons automatiquement permission_add_project: Créer un projet permission_add_subprojects: Créer des sous-projets diff --git a/config/settings.yml b/config/settings.yml index 7520d8e84..baf2b92c4 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -173,6 +173,8 @@ parent_issue_done_ratio: default: 'derived' link_copied_issue: default: 'ask' +close_duplicate_issues: + default: 1 issue_group_assignment: default: 0 default_issue_start_date_to_creation_date: diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 82c1a2720..df242a169 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -1436,6 +1436,23 @@ class IssueTest < ActiveSupport::TestCase assert issue3.reload.closed? end + def test_should_not_close_duplicate_when_disabled + issue = Issue.generate! + duplicate = Issue.generate! + + IssueRelation.create!(:issue_from => duplicate, :issue_to => issue, + :relation_type => IssueRelation::TYPE_DUPLICATES) + assert issue.reload.duplicates.include?(duplicate) + + with_settings :close_duplicate_issues => '0' do + issue.init_journal(User.first, "Closing issue") + issue.status = IssueStatus.where(:is_closed => true).first + issue.save + end + + assert !duplicate.reload.closed? + end + def test_should_close_duplicates_with_private_notes issue = Issue.generate! duplicate = Issue.generate! |