From 3b7da88a839fe518bce0e6c215da834c0779cbaa Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 18 Dec 2016 08:54:26 +0000 Subject: [PATCH] Show an error message when changing an issue's project fails due to errors in child issues (#23888). git-svn-id: http://svn.redmine.org/redmine/trunk@16089 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + config/locales/fr.yml | 1 + test/unit/issue_test.rb | 12 ++++++++++++ 5 files changed, 16 insertions(+) diff --git a/app/models/issue.rb b/app/models/issue.rb index e49890e1a..b515c4a74 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1471,6 +1471,7 @@ class Issue < ActiveRecord::Base # Change project and keep project child.send :project=, project, true unless child.save + errors.add :base, l(:error_move_of_child_not_possible, :child => "##{child.id}", :errors => child.errors.full_messages.join(", ")) raise ActiveRecord::Rollback end end diff --git a/config/locales/de.yml b/config/locales/de.yml index fbb6f9f13..90fd0a63e 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -270,6 +270,7 @@ de: error_unable_to_connect: Fehler beim Verbinden (%{value}) error_workflow_copy_source: Bitte wählen Sie einen Quell-Tracker und eine Quell-Rolle. error_workflow_copy_target: Bitte wählen Sie die Ziel-Tracker und -Rollen. + error_move_of_child_not_possible: "Unteraufgabe %{child} nicht in das neue Projekt verschoben werden konnten: %{errors}" field_account: Konto field_active: Aktiv diff --git a/config/locales/en.yml b/config/locales/en.yml index 669ea472f..d5a854f19 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -216,6 +216,7 @@ en: error_ldap_bind_credentials: "Invalid LDAP Account/Password" error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue" error_no_projects_with_tracker_allowed_for_new_issue: "There are no projects with trackers for which you can create an issue" + error_move_of_child_not_possible: "Subtask %{child} could not be moved to the new project: %{errors}" mail_subject_lost_password: "Your %{value} password" mail_body_lost_password: 'To change your password, click on the following link:' diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a55c1883b..757aa5b48 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -236,6 +236,7 @@ fr: error_ldap_bind_credentials: "Identifiant ou mot de passe LDAP incorrect" error_no_tracker_allowed_for_new_issue_in_project: "Le projet ne dispose d'aucun tracker sur lequel vous pouvez créer une demande" error_no_projects_with_tracker_allowed_for_new_issue: "Aucun projet ne dispose d'un tracker sur lequel vous pouvez créer une demande" + error_move_of_child_not_possible: "La sous-tâche %{child} n'a pas pu être déplacée dans le nouveau projet : %{errors}" mail_subject_lost_password: "Votre mot de passe %{value}" mail_body_lost_password: 'Pour changer votre mot de passe, cliquez sur le lien suivant :' diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index e4e611153..844ed5934 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -1709,6 +1709,18 @@ class IssueTest < ActiveSupport::TestCase assert_equal 3, issue.tracker_id end + def test_move_to_another_project_should_set_error_message_on_child_failure + parent = Issue.generate! + child = Issue.generate!(:parent_issue_id => parent.id, :tracker_id => 2) + project = Project.generate!(:tracker_ids => [1]) + + parent.reload + parent.project_id = project.id + assert !parent.save + assert_include "Subtask ##{child.id} could not be moved to the new project: Tracker is not included in the list", + parent.errors[:base] + end + def test_copy_to_the_same_project issue = Issue.find(1) copy = issue.copy -- 2.39.5