summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-04 20:50:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-04 20:50:27 +0000
commit47d2775977e9273e3f8e3594c5b419945702a84c (patch)
treef8cd2bee61cfafe9dff515ee00176d4e80e211f6
parent66f6d8a6332b898a1b29e9c4e85521b88d560f8f (diff)
downloadredmine-47d2775977e9273e3f8e3594c5b419945702a84c.tar.gz
redmine-47d2775977e9273e3f8e3594c5b419945702a84c.zip
Merged r16118 to r16122 (#24693, #24718, #24722).
git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@16133 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/issues_controller.rb17
-rw-r--r--app/models/issue.rb9
-rw-r--r--app/views/issues/destroy.html.erb2
-rw-r--r--config/locales/ar.yml2
-rw-r--r--config/locales/az.yml2
-rw-r--r--config/locales/bg.yml2
-rw-r--r--config/locales/bs.yml2
-rw-r--r--config/locales/ca.yml2
-rw-r--r--config/locales/cs.yml2
-rw-r--r--config/locales/da.yml2
-rw-r--r--config/locales/de.yml2
-rw-r--r--config/locales/el.yml2
-rw-r--r--config/locales/en-GB.yml2
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/locales/es-PA.yml2
-rw-r--r--config/locales/es.yml2
-rw-r--r--config/locales/et.yml2
-rw-r--r--config/locales/eu.yml2
-rw-r--r--config/locales/fa.yml2
-rw-r--r--config/locales/fi.yml2
-rw-r--r--config/locales/fr.yml1
-rw-r--r--config/locales/gl.yml2
-rw-r--r--config/locales/he.yml2
-rw-r--r--config/locales/hr.yml2
-rw-r--r--config/locales/hu.yml2
-rw-r--r--config/locales/id.yml2
-rw-r--r--config/locales/it.yml2
-rw-r--r--config/locales/ja.yml2
-rw-r--r--config/locales/ko.yml2
-rw-r--r--config/locales/lt.yml2
-rw-r--r--config/locales/lv.yml2
-rw-r--r--config/locales/mk.yml2
-rw-r--r--config/locales/mn.yml2
-rw-r--r--config/locales/nl.yml2
-rw-r--r--config/locales/no.yml2
-rw-r--r--config/locales/pl.yml2
-rw-r--r--config/locales/pt-BR.yml2
-rw-r--r--config/locales/pt.yml2
-rw-r--r--config/locales/ro.yml2
-rw-r--r--config/locales/ru.yml2
-rw-r--r--config/locales/sk.yml2
-rw-r--r--config/locales/sl.yml2
-rw-r--r--config/locales/sq.yml2
-rw-r--r--config/locales/sr-YU.yml2
-rw-r--r--config/locales/sr.yml2
-rw-r--r--config/locales/sv.yml2
-rw-r--r--config/locales/th.yml2
-rw-r--r--config/locales/tr.yml2
-rw-r--r--config/locales/uk.yml2
-rw-r--r--config/locales/vi.yml2
-rw-r--r--config/locales/zh-TW.yml2
-rw-r--r--config/locales/zh.yml2
-rw-r--r--test/functional/issues_controller_test.rb48
53 files changed, 165 insertions, 7 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index c23c1b516..01a127b5b 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -317,21 +317,28 @@ class IssuesController < ApplicationController
end
def destroy
- @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
+
+ # all issues and their descendants are about to be deleted
+ issues_and_descendants_ids = Issue.self_and_descendants(@issues).pluck(:id)
+ time_entries = TimeEntry.where(:issue_id => issues_and_descendants_ids)
+ @hours = time_entries.sum(:hours).to_f
+
if @hours > 0
case params[:todo]
when 'destroy'
# nothing to do
when 'nullify'
- TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL')
+ time_entries.update_all(:issue_id => nil)
when 'reassign'
- reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
+ reassign_to = @project && @project.issues.find_by_id(params[:reassign_to_id])
if reassign_to.nil?
flash.now[:error] = l(:error_issue_not_found_in_project)
return
+ elsif issues_and_descendants_ids.include?(reassign_to.id)
+ flash.now[:error] = l(:error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted)
+ return
else
- TimeEntry.where(['issue_id IN (?)', @issues]).
- update_all("issue_id = #{reassign_to.id}")
+ time_entries.update_all(:issue_id => reassign_to.id, :project_id => reassign_to.project_id)
end
else
# display the destroy form if it's a user request
diff --git a/app/models/issue.rb b/app/models/issue.rb
index c4748609f..2d9ff3eab 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1042,6 +1042,15 @@ class Issue < ActiveRecord::Base
end
end
+ # Returns a scope of the given issues and their descendants
+ def self.self_and_descendants(issues)
+ Issue.joins("JOIN #{Issue.table_name} ancestors" +
+ " ON ancestors.root_id = #{Issue.table_name}.root_id" +
+ " AND ancestors.lft <= #{Issue.table_name}.lft AND ancestors.rgt >= #{Issue.table_name}.rgt"
+ ).
+ where(:ancestors => {:id => issues.map(&:id)})
+ end
+
# Finds an issue relation given its id.
def find_relation(relation_id)
IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
diff --git a/app/views/issues/destroy.html.erb b/app/views/issues/destroy.html.erb
index 4a0631e68..83da014cd 100644
--- a/app/views/issues/destroy.html.erb
+++ b/app/views/issues/destroy.html.erb
@@ -7,8 +7,10 @@
<p>
<label><%= radio_button_tag 'todo', 'destroy', true %> <%= l(:text_destroy_time_entries) %></label><br />
<label><%= radio_button_tag 'todo', 'nullify', false %> <%= l(:text_assign_time_entries_to_project) %></label><br />
+<% if @project %>
<label><%= radio_button_tag 'todo', 'reassign', false, :onchange => 'if (this.checked) { $("#reassign_to_id").focus(); }' %> <%= l(:text_reassign_time_entries) %></label>
<%= text_field_tag 'reassign_to_id', params[:reassign_to_id], :size => 6, :onfocus => '$("#todo_reassign").attr("checked", true);' %>
+<% end %>
</p>
</div>
<%= submit_tag l(:button_apply) %>
diff --git a/config/locales/ar.yml b/config/locales/ar.yml
index 8cd0a88de..2d4230066 100644
--- a/config/locales/ar.yml
+++ b/config/locales/ar.yml
@@ -1182,3 +1182,5 @@ ar:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/az.yml b/config/locales/az.yml
index 9c41d4a79..f83ee4dbd 100644
--- a/config/locales/az.yml
+++ b/config/locales/az.yml
@@ -1277,3 +1277,5 @@ az:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/bg.yml b/config/locales/bg.yml
index 951339213..a45383269 100644
--- a/config/locales/bg.yml
+++ b/config/locales/bg.yml
@@ -1173,3 +1173,5 @@ bg:
description_date_from: Въведете начална дата
description_date_to: Въведете крайна дата
text_repository_identifier_info: 'Позволени са малки букви (a-z), цифри, тирета и _.<br />Промяна след създаването му не е възможна.'
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/bs.yml b/config/locales/bs.yml
index ca4bd0721..bffb4ff51 100644
--- a/config/locales/bs.yml
+++ b/config/locales/bs.yml
@@ -1195,3 +1195,5 @@ bs:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/ca.yml b/config/locales/ca.yml
index d6674a5e5..019203d79 100644
--- a/config/locales/ca.yml
+++ b/config/locales/ca.yml
@@ -1184,3 +1184,5 @@ ca:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/cs.yml b/config/locales/cs.yml
index 1e5616cc6..dbeb0e8a6 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -1183,3 +1183,5 @@ cs:
label_any_open_issues: otevřené úkoly
label_no_open_issues: bez otevřených úkolů
label_default_values_for_new_users: Výchozí hodnoty pro nové uživatele
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/da.yml b/config/locales/da.yml
index e4543d0c8..913c853b2 100644
--- a/config/locales/da.yml
+++ b/config/locales/da.yml
@@ -1199,3 +1199,5 @@ da:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/de.yml b/config/locales/de.yml
index e0fc45a2a..a9ecb7f05 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -1189,3 +1189,5 @@ de:
label_any_open_issues: irgendein offenes Ticket
label_no_open_issues: kein offenes Ticket
label_default_values_for_new_users: Standardwerte für neue Benutzer
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/el.yml b/config/locales/el.yml
index d2022735f..74a5f33d8 100644
--- a/config/locales/el.yml
+++ b/config/locales/el.yml
@@ -1182,3 +1182,5 @@ el:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml
index 2d1e86a62..5f3844d6f 100644
--- a/config/locales/en-GB.yml
+++ b/config/locales/en-GB.yml
@@ -1184,3 +1184,5 @@ en-GB:
setting_attachment_extensions_allowed: Allowed extensions
setting_attachment_extensions_denied: Disallowed extensions
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 7d98034f6..d5e525933 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -212,6 +212,7 @@ en:
error_invalid_csv_file_or_settings: "The file is not a CSV file or does not match the settings below"
error_can_not_read_import_file: "An error occurred while reading the file to import"
error_attachment_extension_not_allowed: "Attachment extension %{extension} is not allowed"
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: "Spent time cannot be reassigned to an issue that is about to be deleted"
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/es-PA.yml b/config/locales/es-PA.yml
index 926d4f85a..3afb5db85 100644
--- a/config/locales/es-PA.yml
+++ b/config/locales/es-PA.yml
@@ -1216,3 +1216,5 @@ es-PA:
label_any_open_issues: cualquier incidencias abierta
label_no_open_issues: incidencias cerradas
label_default_values_for_new_users: Valor predeterminado para nuevos usuarios
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/es.yml b/config/locales/es.yml
index b62e066b3..d89e8991c 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -1214,3 +1214,5 @@ es:
label_any_open_issues: cualquier peticiones abierta
label_no_open_issues: peticiones cerradas
label_default_values_for_new_users: Valor predeterminado para nuevos usuarios
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/et.yml b/config/locales/et.yml
index 87a94c512..9210e0249 100644
--- a/config/locales/et.yml
+++ b/config/locales/et.yml
@@ -1195,3 +1195,5 @@ et:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/eu.yml b/config/locales/eu.yml
index 20e7222cd..4ea30f9b1 100644
--- a/config/locales/eu.yml
+++ b/config/locales/eu.yml
@@ -1183,3 +1183,5 @@ eu:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/fa.yml b/config/locales/fa.yml
index 3ffc47486..d0716e7a4 100644
--- a/config/locales/fa.yml
+++ b/config/locales/fa.yml
@@ -1183,3 +1183,5 @@ fa:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/fi.yml b/config/locales/fi.yml
index 5021546cf..0c718749b 100644
--- a/config/locales/fi.yml
+++ b/config/locales/fi.yml
@@ -1203,3 +1203,5 @@ fi:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 43873caf3..c68f766c6 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -232,6 +232,7 @@ fr:
error_invalid_csv_file_or_settings: "Le fichier n'est pas un fichier CSV ou n'est pas conforme aux paramètres sélectionnés"
error_can_not_read_import_file: "Une erreur est survenue lors de la lecture du fichier à importer"
error_attachment_extension_not_allowed: "L'extension %{extension} n'est pas autorisée"
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: "Le temps passé ne peut pas être réaffecté à une demande qui va être supprimée"
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/config/locales/gl.yml b/config/locales/gl.yml
index 381c2c9e7..670ad8099 100644
--- a/config/locales/gl.yml
+++ b/config/locales/gl.yml
@@ -1190,3 +1190,5 @@ gl:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/he.yml b/config/locales/he.yml
index cf5a1dd0e..ab17a94b3 100644
--- a/config/locales/he.yml
+++ b/config/locales/he.yml
@@ -1187,3 +1187,5 @@ he:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/hr.yml b/config/locales/hr.yml
index 079ddfd8d..e71614afb 100644
--- a/config/locales/hr.yml
+++ b/config/locales/hr.yml
@@ -1181,3 +1181,5 @@ hr:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/hu.yml b/config/locales/hu.yml
index 026d89fba..5e7e2b64b 100644
--- a/config/locales/hu.yml
+++ b/config/locales/hu.yml
@@ -1201,3 +1201,5 @@
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/id.yml b/config/locales/id.yml
index 01a9304dc..a3f2c4115 100644
--- a/config/locales/id.yml
+++ b/config/locales/id.yml
@@ -1186,3 +1186,5 @@ id:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/it.yml b/config/locales/it.yml
index 0f9da368a..7ba3a923b 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -1177,3 +1177,5 @@ it:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index 7fe0d40ec..1d4901b36 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1195,3 +1195,5 @@ ja:
label_any_open_issues: 未完了のチケット
label_no_open_issues: なし または完了したチケット
label_default_values_for_new_users: 新しいユーザーのデフォルト設定
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/ko.yml b/config/locales/ko.yml
index 79ea12487..a92128eb5 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -1223,3 +1223,5 @@ ko:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: 새 사용자 기본값
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/lt.yml b/config/locales/lt.yml
index 649835377..0c020a9fc 100644
--- a/config/locales/lt.yml
+++ b/config/locales/lt.yml
@@ -1241,3 +1241,5 @@ lt:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/lv.yml b/config/locales/lv.yml
index bcee88d6c..91ed269fc 100644
--- a/config/locales/lv.yml
+++ b/config/locales/lv.yml
@@ -1176,3 +1176,5 @@ lv:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/mk.yml b/config/locales/mk.yml
index 6c7a2af08..eab7b730d 100644
--- a/config/locales/mk.yml
+++ b/config/locales/mk.yml
@@ -1182,3 +1182,5 @@ mk:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/mn.yml b/config/locales/mn.yml
index c5a74e06f..974717a46 100644
--- a/config/locales/mn.yml
+++ b/config/locales/mn.yml
@@ -1183,3 +1183,5 @@ mn:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 9a2a17542..7fdfab7c3 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -1161,3 +1161,5 @@ nl:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/no.yml b/config/locales/no.yml
index 35f2b8e91..b01f4c1ee 100644
--- a/config/locales/no.yml
+++ b/config/locales/no.yml
@@ -1172,3 +1172,5 @@
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/pl.yml b/config/locales/pl.yml
index 50cd2f39c..a65a34afa 100644
--- a/config/locales/pl.yml
+++ b/config/locales/pl.yml
@@ -1197,3 +1197,5 @@ pl:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index 43f8b329b..2ae583a17 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -1201,3 +1201,5 @@ pt-BR:
label_any_open_issues: Quaisquer tarefas abertas
label_no_open_issues: Sem tarefas abertas
label_default_values_for_new_users: Valor padrão para novos usuários
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/pt.yml b/config/locales/pt.yml
index da696f2b3..e3184c1ed 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -1184,3 +1184,5 @@ pt:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/ro.yml b/config/locales/ro.yml
index 2e89625a1..d75cec27a 100644
--- a/config/locales/ro.yml
+++ b/config/locales/ro.yml
@@ -1177,3 +1177,5 @@ ro:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index d506da153..95579c530 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -1283,3 +1283,5 @@ ru:
label_any_open_issues: любые открытые задачи
label_no_open_issues: нет открытых задач
label_default_values_for_new_users: Значения по умолчанию для новых пользователей
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/sk.yml b/config/locales/sk.yml
index 0508f1fe5..f2779fea5 100644
--- a/config/locales/sk.yml
+++ b/config/locales/sk.yml
@@ -1172,3 +1172,5 @@ sk:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/sl.yml b/config/locales/sl.yml
index 56742220d..74caf2d94 100644
--- a/config/locales/sl.yml
+++ b/config/locales/sl.yml
@@ -1182,3 +1182,5 @@ sl:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/sq.yml b/config/locales/sq.yml
index fd2fdd33d..a1754e751 100644
--- a/config/locales/sq.yml
+++ b/config/locales/sq.yml
@@ -1178,3 +1178,5 @@ sq:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/sr-YU.yml b/config/locales/sr-YU.yml
index 3b30b09a8..dd02721b3 100644
--- a/config/locales/sr-YU.yml
+++ b/config/locales/sr-YU.yml
@@ -1184,3 +1184,5 @@ sr-YU:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/sr.yml b/config/locales/sr.yml
index 89e5cfa96..4762e7aa5 100644
--- a/config/locales/sr.yml
+++ b/config/locales/sr.yml
@@ -1183,3 +1183,5 @@ sr:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/sv.yml b/config/locales/sv.yml
index 73be757c9..4cb85264f 100644
--- a/config/locales/sv.yml
+++ b/config/locales/sv.yml
@@ -1215,3 +1215,5 @@ sv:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/th.yml b/config/locales/th.yml
index 122fcd4e1..14d728308 100644
--- a/config/locales/th.yml
+++ b/config/locales/th.yml
@@ -1179,3 +1179,5 @@ th:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/tr.yml b/config/locales/tr.yml
index 0f700fd47..55e8be755 100644
--- a/config/locales/tr.yml
+++ b/config/locales/tr.yml
@@ -1189,3 +1189,5 @@ tr:
label_any_open_issues: herhangi bir açık iş
label_no_open_issues: hiçbir açık iş
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/uk.yml b/config/locales/uk.yml
index 077bfbad3..fae40b0d1 100644
--- a/config/locales/uk.yml
+++ b/config/locales/uk.yml
@@ -1177,3 +1177,5 @@ uk:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/vi.yml b/config/locales/vi.yml
index 632e44624..f71f64617 100644
--- a/config/locales/vi.yml
+++ b/config/locales/vi.yml
@@ -1235,3 +1235,5 @@ vi:
label_any_open_issues: any open issues
label_no_open_issues: no open issues
label_default_values_for_new_users: Default values for new users
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml
index c87ba150a..cdbba4f5f 100644
--- a/config/locales/zh-TW.yml
+++ b/config/locales/zh-TW.yml
@@ -1256,3 +1256,5 @@
description_date_from: 輸入起始日期
description_date_to: 輸入結束日期
text_repository_identifier_info: '僅允許使用小寫英文字母 (a-z), 阿拉伯數字, 虛線與底線。<br />一旦儲存之後, 代碼便無法再次被更改。'
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index fbae07878..8382f1a2f 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -1177,3 +1177,5 @@ zh:
label_any_open_issues: 任意进行中的问题
label_no_open_issues: 任意已关闭的问题
label_default_values_for_new_users: 新用户默认值
+ error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
+ be reassigned to an issue that is about to be deleted
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 8a8ae6c76..9c2906e87 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -4442,7 +4442,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_response :success
end
- def test_destroy_issue_with_no_time_entries
+ def test_destroy_issue_with_no_time_entries_should_delete_the_issues
assert_nil TimeEntry.find_by_issue_id(2)
@request.session[:user_id] = 2
@@ -4453,7 +4453,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_nil Issue.find_by_id(2)
end
- def test_destroy_issues_with_time_entries
+ def test_destroy_issues_with_time_entries_should_show_the_reassign_form
@request.session[:user_id] = 2
assert_no_difference 'Issue.count' do
@@ -4469,6 +4469,20 @@ class IssuesControllerTest < ActionController::TestCase
end
end
+ def test_destroy_issues_with_time_entries_should_show_hours_on_issues_and_descendants
+ parent = Issue.generate_with_child!
+ TimeEntry.generate!(:issue => parent)
+ TimeEntry.generate!(:issue => parent.children.first)
+ leaf = Issue.generate!
+ TimeEntry.generate!(:issue => leaf)
+ @request.session[:user_id] = 2
+
+ delete :destroy, :ids => [parent.id, leaf.id]
+ assert_response :success
+
+ assert_select 'p', :text => /3\.00 hours were reported/
+ end
+
def test_destroy_issues_and_destroy_time_entries
@request.session[:user_id] = 2
@@ -4510,6 +4524,24 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal 2, TimeEntry.find(2).issue_id
end
+ def test_destroy_issues_with_time_entries_should_reassign_time_entries_of_issues_and_descendants
+ parent = Issue.generate_with_child!
+ TimeEntry.generate!(:issue => parent)
+ TimeEntry.generate!(:issue => parent.children.first)
+ leaf = Issue.generate!
+ TimeEntry.generate!(:issue => leaf)
+ target = Issue.generate!
+ @request.session[:user_id] = 2
+
+ assert_difference 'Issue.count', -3 do
+ assert_no_difference 'TimeEntry.count' do
+ delete :destroy, :ids => [parent.id, leaf.id], :todo => 'reassign', :reassign_to_id => target.id
+ assert_response 302
+ end
+ end
+ assert_equal 3, target.time_entries.count
+ end
+
def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail
@request.session[:user_id] = 2
@@ -4523,6 +4555,18 @@ class IssuesControllerTest < ActionController::TestCase
assert_template 'destroy'
end
+ def test_destroy_issues_and_reassign_time_entries_to_an_issue_to_delete_should_fail
+ @request.session[:user_id] = 2
+
+ assert_no_difference 'Issue.count' do
+ assert_no_difference 'TimeEntry.count' do
+ delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 3
+ end
+ end
+ assert_response :success
+ assert_select '#flash_error', :text => I18n.t(:error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted)
+ end
+
def test_destroy_issues_from_different_projects
@request.session[:user_id] = 2