diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index c640aad..a3cd8fb 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -325,21 +325,28 @@ class IssuesController < ApplicationController
def destroy
raise Unauthorized unless @issues.all?(&:deletable?)
- @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 58d51e1..f569ed0 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1081,6 +1081,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 4a0631e..83da014 100644
--- a/app/views/issues/destroy.html.erb
+++ b/app/views/issues/destroy.html.erb
@@ -7,8 +7,10 @@
+<% if @project %>
<%= text_field_tag 'reassign_to_id', params[:reassign_to_id], :size => 6, :onfocus => '$("#todo_reassign").attr("checked", true);' %>
+<% end %>
<%= submit_tag l(:button_apply) %>
diff --git a/config/locales/ar.yml b/config/locales/ar.yml
index 068a9a0..509d185 100644
--- a/config/locales/ar.yml
+++ b/config/locales/ar.yml
@@ -1208,3 +1208,5 @@ ar:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 4f3c385..314d126 100644
--- a/config/locales/az.yml
+++ b/config/locales/az.yml
@@ -1303,3 +1303,5 @@ az:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 dceed2c..3b2de0d 100644
--- a/config/locales/bg.yml
+++ b/config/locales/bg.yml
@@ -1196,3 +1196,5 @@ bg:
text_repository_identifier_info: 'Позволени са малки букви (a-z), цифри, тирета и _. Промяна след създаването му не е възможна.'
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 058da4b..900255d 100644
--- a/config/locales/bs.yml
+++ b/config/locales/bs.yml
@@ -1221,3 +1221,5 @@ bs:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 67a76b7..32186d2 100644
--- a/config/locales/ca.yml
+++ b/config/locales/ca.yml
@@ -1198,3 +1198,5 @@ ca:
setting_new_item_menu_tab: Pestanya de nous objectes en el menu de cada projecte
label_new_object_tab_enabled: Mostrar el llistat desplegable "+"
error_no_projects_with_tracker_allowed_for_new_issue: "Cap projecte disposa d'un tipus d'assumpte sobre el qual vostè pugui crear un assumpte"
+ 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 03ea130..8dcbae7 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -1209,3 +1209,5 @@ cs:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 5d0bdb9..7511d33 100644
--- a/config/locales/da.yml
+++ b/config/locales/da.yml
@@ -1225,3 +1225,5 @@ da:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 5d5509a..bb89df3 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -1211,3 +1211,5 @@ de:
label_new_object_tab_enabled: Dropdown-Menü "+" anzeigen
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 aae2c61..a28ae0c 100644
--- a/config/locales/el.yml
+++ b/config/locales/el.yml
@@ -1208,3 +1208,5 @@ el:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 f0838a1..7e7271f 100644
--- a/config/locales/en-GB.yml
+++ b/config/locales/en-GB.yml
@@ -1210,3 +1210,5 @@ en-GB:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 a6501c3..399c2e8 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -215,6 +215,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_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 4787cfa..adefd60 100644
--- a/config/locales/es-PA.yml
+++ b/config/locales/es-PA.yml
@@ -1238,3 +1238,5 @@ es-PA:
setting_new_item_menu_tab: Pestaña de creación de nuevos objetos en el menú de cada proyecto
label_new_object_tab_enabled: Mostrar la lista desplegable "+"
error_no_projects_with_tracker_allowed_for_new_issue: Ningún proyecto dispone de un tipo sobre el cual puedas crear una petición
+ 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 afebdc1..fe83898 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -1236,3 +1236,5 @@ es:
setting_new_item_menu_tab: Pestaña de creación de nuevos objetos en el menú de cada proyecto
label_new_object_tab_enabled: Mostrar la lista desplegable "+"
error_no_projects_with_tracker_allowed_for_new_issue: Ningún proyecto dispone de un tipo sobre el cual puedas crear una petición
+ 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 e60bae4..117bed5 100644
--- a/config/locales/et.yml
+++ b/config/locales/et.yml
@@ -1213,3 +1213,5 @@ et:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 22a6337..20b2066 100644
--- a/config/locales/eu.yml
+++ b/config/locales/eu.yml
@@ -1209,3 +1209,5 @@ eu:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 8611eed..e8404cf 100644
--- a/config/locales/fa.yml
+++ b/config/locales/fa.yml
@@ -1209,3 +1209,5 @@ fa:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 5685d97..acafa9b 100644
--- a/config/locales/fi.yml
+++ b/config/locales/fi.yml
@@ -1229,3 +1229,5 @@ fi:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 50fe2b9..502b120 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -235,6 +235,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_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 9706359..5bfd4f0 100644
--- a/config/locales/gl.yml
+++ b/config/locales/gl.yml
@@ -1216,3 +1216,5 @@ gl:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 903ce46..5be5d04 100644
--- a/config/locales/he.yml
+++ b/config/locales/he.yml
@@ -1213,3 +1213,5 @@ he:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 982bac6..19a8a25 100644
--- a/config/locales/hr.yml
+++ b/config/locales/hr.yml
@@ -1207,3 +1207,5 @@ hr:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 b23cbc6..676ce38 100644
--- a/config/locales/hu.yml
+++ b/config/locales/hu.yml
@@ -1227,3 +1227,5 @@
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 885323d..e9dffd7 100644
--- a/config/locales/id.yml
+++ b/config/locales/id.yml
@@ -1212,3 +1212,5 @@ id:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 a02d79b..1193a17 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -1203,3 +1203,5 @@ it:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 ba5d8f9..ca8757f 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1219,3 +1219,5 @@ ja:
label_new_object_tab_enabled: '"+" ドロップダウンを表示'
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 b0829b9..de4a22f 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -1247,3 +1247,5 @@ ko:
label_new_object_tab_enabled: 메뉴에 "+" 탭 표시
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 03bc28f..7ae36cf 100644
--- a/config/locales/lt.yml
+++ b/config/locales/lt.yml
@@ -1197,3 +1197,5 @@ lt:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 63f74e6..41345cc 100644
--- a/config/locales/lv.yml
+++ b/config/locales/lv.yml
@@ -1202,3 +1202,5 @@ lv:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 ee42c57..26637b0 100644
--- a/config/locales/mk.yml
+++ b/config/locales/mk.yml
@@ -1208,3 +1208,5 @@ mk:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 ebbf6e1..943eb5a 100644
--- a/config/locales/mn.yml
+++ b/config/locales/mn.yml
@@ -1209,3 +1209,5 @@ mn:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 372d0c3..2c99a61 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -1187,3 +1187,5 @@ nl:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 1ace8d9..9a02d7b 100644
--- a/config/locales/no.yml
+++ b/config/locales/no.yml
@@ -1198,3 +1198,5 @@
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 880b8f2..ecbbc9f 100644
--- a/config/locales/pl.yml
+++ b/config/locales/pl.yml
@@ -1223,3 +1223,5 @@ pl:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 5c9e5bd..b7e0ab1 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -1226,3 +1226,5 @@ pt-BR:
label_new_object_tab_enabled: Exibir o "+" suspenso
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 8038ad1..64f6961 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -1211,3 +1211,5 @@ pt:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 1571c16..3e0de03 100644
--- a/config/locales/ro.yml
+++ b/config/locales/ro.yml
@@ -1203,3 +1203,5 @@ ro:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 5e160af..9afbb02 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -1310,3 +1310,5 @@ ru:
label_new_object_tab_enabled: Отображать выпадающий список "+"
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 b05ca62..fb5c325 100644
--- a/config/locales/sk.yml
+++ b/config/locales/sk.yml
@@ -1198,3 +1198,5 @@ sk:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 c2aa76e..b4b217a 100644
--- a/config/locales/sl.yml
+++ b/config/locales/sl.yml
@@ -1208,3 +1208,5 @@ sl:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 819edc8..cc38be2 100644
--- a/config/locales/sq.yml
+++ b/config/locales/sq.yml
@@ -1204,3 +1204,5 @@ sq:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 f61b454..6ef7aba 100644
--- a/config/locales/sr-YU.yml
+++ b/config/locales/sr-YU.yml
@@ -1210,3 +1210,5 @@ sr-YU:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 964f4a4..6c7100f 100644
--- a/config/locales/sr.yml
+++ b/config/locales/sr.yml
@@ -1209,3 +1209,5 @@ sr:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 ff681f1..5d67781 100644
--- a/config/locales/sv.yml
+++ b/config/locales/sv.yml
@@ -1241,3 +1241,5 @@ sv:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 984d5e1..05574aa 100644
--- a/config/locales/th.yml
+++ b/config/locales/th.yml
@@ -1205,3 +1205,5 @@ th:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 7822ca2..ae29dd9 100644
--- a/config/locales/tr.yml
+++ b/config/locales/tr.yml
@@ -1216,3 +1216,5 @@ tr:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 7a23e9e..cde94f8 100644
--- a/config/locales/uk.yml
+++ b/config/locales/uk.yml
@@ -1203,3 +1203,5 @@ uk:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 cd872c5..bd3aad6 100644
--- a/config/locales/vi.yml
+++ b/config/locales/vi.yml
@@ -1261,3 +1261,5 @@ vi:
label_new_object_tab_enabled: Display the "+" drop-down
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 15486af..bcdb15e 100644
--- a/config/locales/zh-TW.yml
+++ b/config/locales/zh-TW.yml
@@ -1278,3 +1278,5 @@
description_date_from: 輸入起始日期
description_date_to: 輸入結束日期
text_repository_identifier_info: '僅允許使用小寫英文字母 (a-z), 阿拉伯數字, 虛線與底線。 一旦儲存之後, 代碼便無法再次被更改。'
+ 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 4ccee76..88da0bd 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -1201,3 +1201,5 @@ zh:
label_new_object_tab_enabled: 显示 "+" 为下拉列表
error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
for which you can create an issue
+ 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 99b3ed0..181bd86 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -4687,7 +4687,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
@@ -4698,7 +4698,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
@@ -4714,6 +4714,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
@@ -4755,6 +4769,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
@@ -4768,6 +4800,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