##// END OF EJS Templates
Merged r16118 to r16122 (#24693, #24718, #24722)....
Jean-Philippe Lang -
r15750:c4b1ab644ee6
parent child
Show More
@@ -325,21 +325,28 class IssuesController < ApplicationController
325 325
326 326 def destroy
327 327 raise Unauthorized unless @issues.all?(&:deletable?)
328 @hours = TimeEntry.where(:issue_id => @issues.map(&:id)).sum(:hours).to_f
328
329 # all issues and their descendants are about to be deleted
330 issues_and_descendants_ids = Issue.self_and_descendants(@issues).pluck(:id)
331 time_entries = TimeEntry.where(:issue_id => issues_and_descendants_ids)
332 @hours = time_entries.sum(:hours).to_f
333
329 334 if @hours > 0
330 335 case params[:todo]
331 336 when 'destroy'
332 337 # nothing to do
333 338 when 'nullify'
334 TimeEntry.where(['issue_id IN (?)', @issues]).update_all('issue_id = NULL')
339 time_entries.update_all(:issue_id => nil)
335 340 when 'reassign'
336 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
341 reassign_to = @project && @project.issues.find_by_id(params[:reassign_to_id])
337 342 if reassign_to.nil?
338 343 flash.now[:error] = l(:error_issue_not_found_in_project)
339 344 return
345 elsif issues_and_descendants_ids.include?(reassign_to.id)
346 flash.now[:error] = l(:error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted)
347 return
340 348 else
341 TimeEntry.where(['issue_id IN (?)', @issues]).
342 update_all("issue_id = #{reassign_to.id}")
349 time_entries.update_all(:issue_id => reassign_to.id, :project_id => reassign_to.project_id)
343 350 end
344 351 else
345 352 # display the destroy form if it's a user request
@@ -1081,6 +1081,15 class Issue < ActiveRecord::Base
1081 1081 end
1082 1082 end
1083 1083
1084 # Returns a scope of the given issues and their descendants
1085 def self.self_and_descendants(issues)
1086 Issue.joins("JOIN #{Issue.table_name} ancestors" +
1087 " ON ancestors.root_id = #{Issue.table_name}.root_id" +
1088 " AND ancestors.lft <= #{Issue.table_name}.lft AND ancestors.rgt >= #{Issue.table_name}.rgt"
1089 ).
1090 where(:ancestors => {:id => issues.map(&:id)})
1091 end
1092
1084 1093 # Finds an issue relation given its id.
1085 1094 def find_relation(relation_id)
1086 1095 IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
@@ -7,8 +7,10
7 7 <p>
8 8 <label><%= radio_button_tag 'todo', 'destroy', true %> <%= l(:text_destroy_time_entries) %></label><br />
9 9 <label><%= radio_button_tag 'todo', 'nullify', false %> <%= l(:text_assign_time_entries_to_project) %></label><br />
10 <% if @project %>
10 11 <label><%= radio_button_tag 'todo', 'reassign', false, :onchange => 'if (this.checked) { $("#reassign_to_id").focus(); }' %> <%= l(:text_reassign_time_entries) %></label>
11 12 <%= text_field_tag 'reassign_to_id', params[:reassign_to_id], :size => 6, :onfocus => '$("#todo_reassign").attr("checked", true);' %>
13 <% end %>
12 14 </p>
13 15 </div>
14 16 <%= submit_tag l(:button_apply) %>
@@ -1208,3 +1208,5 ar:
1208 1208 label_new_object_tab_enabled: Display the "+" drop-down
1209 1209 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1210 1210 for which you can create an issue
1211 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1212 be reassigned to an issue that is about to be deleted
@@ -1303,3 +1303,5 az:
1303 1303 label_new_object_tab_enabled: Display the "+" drop-down
1304 1304 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1305 1305 for which you can create an issue
1306 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1307 be reassigned to an issue that is about to be deleted
@@ -1196,3 +1196,5 bg:
1196 1196 text_repository_identifier_info: 'Позволени са малки букви (a-z), цифри, тирета и _.<br />Промяна след създаването му не е възможна.'
1197 1197 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1198 1198 for which you can create an issue
1199 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1200 be reassigned to an issue that is about to be deleted
@@ -1221,3 +1221,5 bs:
1221 1221 label_new_object_tab_enabled: Display the "+" drop-down
1222 1222 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1223 1223 for which you can create an issue
1224 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1225 be reassigned to an issue that is about to be deleted
@@ -1198,3 +1198,5 ca:
1198 1198 setting_new_item_menu_tab: Pestanya de nous objectes en el menu de cada projecte
1199 1199 label_new_object_tab_enabled: Mostrar el llistat desplegable "+"
1200 1200 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"
1201 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1202 be reassigned to an issue that is about to be deleted
@@ -1209,3 +1209,5 cs:
1209 1209 label_new_object_tab_enabled: Display the "+" drop-down
1210 1210 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1211 1211 for which you can create an issue
1212 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1213 be reassigned to an issue that is about to be deleted
@@ -1225,3 +1225,5 da:
1225 1225 label_new_object_tab_enabled: Display the "+" drop-down
1226 1226 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1227 1227 for which you can create an issue
1228 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1229 be reassigned to an issue that is about to be deleted
@@ -1211,3 +1211,5 de:
1211 1211 label_new_object_tab_enabled: Dropdown-Menü "+" anzeigen
1212 1212 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1213 1213 for which you can create an issue
1214 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1215 be reassigned to an issue that is about to be deleted
@@ -1208,3 +1208,5 el:
1208 1208 label_new_object_tab_enabled: Display the "+" drop-down
1209 1209 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1210 1210 for which you can create an issue
1211 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1212 be reassigned to an issue that is about to be deleted
@@ -1210,3 +1210,5 en-GB:
1210 1210 label_new_object_tab_enabled: Display the "+" drop-down
1211 1211 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1212 1212 for which you can create an issue
1213 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1214 be reassigned to an issue that is about to be deleted
@@ -215,6 +215,7 en:
215 215 error_ldap_bind_credentials: "Invalid LDAP Account/Password"
216 216 error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue"
217 217 error_no_projects_with_tracker_allowed_for_new_issue: "There are no projects with trackers for which you can create an issue"
218 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"
218 219
219 220 mail_subject_lost_password: "Your %{value} password"
220 221 mail_body_lost_password: 'To change your password, click on the following link:'
@@ -1238,3 +1238,5 es-PA:
1238 1238 setting_new_item_menu_tab: Pestaña de creación de nuevos objetos en el menú de cada proyecto
1239 1239 label_new_object_tab_enabled: Mostrar la lista desplegable "+"
1240 1240 error_no_projects_with_tracker_allowed_for_new_issue: Ningún proyecto dispone de un tipo sobre el cual puedas crear una petición
1241 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1242 be reassigned to an issue that is about to be deleted
@@ -1236,3 +1236,5 es:
1236 1236 setting_new_item_menu_tab: Pestaña de creación de nuevos objetos en el menú de cada proyecto
1237 1237 label_new_object_tab_enabled: Mostrar la lista desplegable "+"
1238 1238 error_no_projects_with_tracker_allowed_for_new_issue: Ningún proyecto dispone de un tipo sobre el cual puedas crear una petición
1239 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1240 be reassigned to an issue that is about to be deleted
@@ -1213,3 +1213,5 et:
1213 1213 label_new_object_tab_enabled: Display the "+" drop-down
1214 1214 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1215 1215 for which you can create an issue
1216 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1217 be reassigned to an issue that is about to be deleted
@@ -1209,3 +1209,5 eu:
1209 1209 label_new_object_tab_enabled: Display the "+" drop-down
1210 1210 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1211 1211 for which you can create an issue
1212 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1213 be reassigned to an issue that is about to be deleted
@@ -1209,3 +1209,5 fa:
1209 1209 label_new_object_tab_enabled: Display the "+" drop-down
1210 1210 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1211 1211 for which you can create an issue
1212 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1213 be reassigned to an issue that is about to be deleted
@@ -1229,3 +1229,5 fi:
1229 1229 label_new_object_tab_enabled: Display the "+" drop-down
1230 1230 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1231 1231 for which you can create an issue
1232 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1233 be reassigned to an issue that is about to be deleted
@@ -235,6 +235,7 fr:
235 235 error_ldap_bind_credentials: "Identifiant ou mot de passe LDAP incorrect"
236 236 error_no_tracker_allowed_for_new_issue_in_project: "Le projet ne dispose d'aucun tracker sur lequel vous pouvez créer une demande"
237 237 error_no_projects_with_tracker_allowed_for_new_issue: "Aucun projet ne dispose d'un tracker sur lequel vous pouvez créer une demande"
238 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"
238 239
239 240 mail_subject_lost_password: "Votre mot de passe %{value}"
240 241 mail_body_lost_password: 'Pour changer votre mot de passe, cliquez sur le lien suivant :'
@@ -1216,3 +1216,5 gl:
1216 1216 label_new_object_tab_enabled: Display the "+" drop-down
1217 1217 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1218 1218 for which you can create an issue
1219 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1220 be reassigned to an issue that is about to be deleted
@@ -1213,3 +1213,5 he:
1213 1213 label_new_object_tab_enabled: Display the "+" drop-down
1214 1214 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1215 1215 for which you can create an issue
1216 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1217 be reassigned to an issue that is about to be deleted
@@ -1207,3 +1207,5 hr:
1207 1207 label_new_object_tab_enabled: Display the "+" drop-down
1208 1208 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1209 1209 for which you can create an issue
1210 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1211 be reassigned to an issue that is about to be deleted
@@ -1227,3 +1227,5
1227 1227 label_new_object_tab_enabled: Display the "+" drop-down
1228 1228 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1229 1229 for which you can create an issue
1230 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1231 be reassigned to an issue that is about to be deleted
@@ -1212,3 +1212,5 id:
1212 1212 label_new_object_tab_enabled: Display the "+" drop-down
1213 1213 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1214 1214 for which you can create an issue
1215 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1216 be reassigned to an issue that is about to be deleted
@@ -1203,3 +1203,5 it:
1203 1203 label_new_object_tab_enabled: Display the "+" drop-down
1204 1204 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1205 1205 for which you can create an issue
1206 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1207 be reassigned to an issue that is about to be deleted
@@ -1219,3 +1219,5 ja:
1219 1219 label_new_object_tab_enabled: '"+" ドロップダウンを表示'
1220 1220 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1221 1221 for which you can create an issue
1222 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1223 be reassigned to an issue that is about to be deleted
@@ -1247,3 +1247,5 ko:
1247 1247 label_new_object_tab_enabled: 메뉴에 "+" 탭 표시
1248 1248 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1249 1249 for which you can create an issue
1250 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1251 be reassigned to an issue that is about to be deleted
@@ -1197,3 +1197,5 lt:
1197 1197 label_new_object_tab_enabled: Display the "+" drop-down
1198 1198 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1199 1199 for which you can create an issue
1200 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1201 be reassigned to an issue that is about to be deleted
@@ -1202,3 +1202,5 lv:
1202 1202 label_new_object_tab_enabled: Display the "+" drop-down
1203 1203 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1204 1204 for which you can create an issue
1205 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1206 be reassigned to an issue that is about to be deleted
@@ -1208,3 +1208,5 mk:
1208 1208 label_new_object_tab_enabled: Display the "+" drop-down
1209 1209 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1210 1210 for which you can create an issue
1211 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1212 be reassigned to an issue that is about to be deleted
@@ -1209,3 +1209,5 mn:
1209 1209 label_new_object_tab_enabled: Display the "+" drop-down
1210 1210 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1211 1211 for which you can create an issue
1212 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1213 be reassigned to an issue that is about to be deleted
@@ -1187,3 +1187,5 nl:
1187 1187 label_new_object_tab_enabled: Display the "+" drop-down
1188 1188 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1189 1189 for which you can create an issue
1190 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1191 be reassigned to an issue that is about to be deleted
@@ -1198,3 +1198,5
1198 1198 label_new_object_tab_enabled: Display the "+" drop-down
1199 1199 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1200 1200 for which you can create an issue
1201 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1202 be reassigned to an issue that is about to be deleted
@@ -1223,3 +1223,5 pl:
1223 1223 label_new_object_tab_enabled: Display the "+" drop-down
1224 1224 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1225 1225 for which you can create an issue
1226 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1227 be reassigned to an issue that is about to be deleted
@@ -1226,3 +1226,5 pt-BR:
1226 1226 label_new_object_tab_enabled: Exibir o "+" suspenso
1227 1227 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1228 1228 for which you can create an issue
1229 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1230 be reassigned to an issue that is about to be deleted
@@ -1211,3 +1211,5 pt:
1211 1211 label_new_object_tab_enabled: Display the "+" drop-down
1212 1212 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1213 1213 for which you can create an issue
1214 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1215 be reassigned to an issue that is about to be deleted
@@ -1203,3 +1203,5 ro:
1203 1203 label_new_object_tab_enabled: Display the "+" drop-down
1204 1204 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1205 1205 for which you can create an issue
1206 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1207 be reassigned to an issue that is about to be deleted
@@ -1310,3 +1310,5 ru:
1310 1310 label_new_object_tab_enabled: Отображать выпадающий список "+"
1311 1311 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1312 1312 for which you can create an issue
1313 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1314 be reassigned to an issue that is about to be deleted
@@ -1198,3 +1198,5 sk:
1198 1198 label_new_object_tab_enabled: Display the "+" drop-down
1199 1199 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1200 1200 for which you can create an issue
1201 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1202 be reassigned to an issue that is about to be deleted
@@ -1208,3 +1208,5 sl:
1208 1208 label_new_object_tab_enabled: Display the "+" drop-down
1209 1209 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1210 1210 for which you can create an issue
1211 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1212 be reassigned to an issue that is about to be deleted
@@ -1204,3 +1204,5 sq:
1204 1204 label_new_object_tab_enabled: Display the "+" drop-down
1205 1205 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1206 1206 for which you can create an issue
1207 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1208 be reassigned to an issue that is about to be deleted
@@ -1210,3 +1210,5 sr-YU:
1210 1210 label_new_object_tab_enabled: Display the "+" drop-down
1211 1211 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1212 1212 for which you can create an issue
1213 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1214 be reassigned to an issue that is about to be deleted
@@ -1209,3 +1209,5 sr:
1209 1209 label_new_object_tab_enabled: Display the "+" drop-down
1210 1210 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1211 1211 for which you can create an issue
1212 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1213 be reassigned to an issue that is about to be deleted
@@ -1241,3 +1241,5 sv:
1241 1241 label_new_object_tab_enabled: Display the "+" drop-down
1242 1242 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1243 1243 for which you can create an issue
1244 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1245 be reassigned to an issue that is about to be deleted
@@ -1205,3 +1205,5 th:
1205 1205 label_new_object_tab_enabled: Display the "+" drop-down
1206 1206 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1207 1207 for which you can create an issue
1208 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1209 be reassigned to an issue that is about to be deleted
@@ -1216,3 +1216,5 tr:
1216 1216 label_new_object_tab_enabled: Display the "+" drop-down
1217 1217 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1218 1218 for which you can create an issue
1219 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1220 be reassigned to an issue that is about to be deleted
@@ -1203,3 +1203,5 uk:
1203 1203 label_new_object_tab_enabled: Display the "+" drop-down
1204 1204 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1205 1205 for which you can create an issue
1206 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1207 be reassigned to an issue that is about to be deleted
@@ -1261,3 +1261,5 vi:
1261 1261 label_new_object_tab_enabled: Display the "+" drop-down
1262 1262 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1263 1263 for which you can create an issue
1264 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1265 be reassigned to an issue that is about to be deleted
@@ -1278,3 +1278,5
1278 1278 description_date_from: 輸入起始日期
1279 1279 description_date_to: 輸入結束日期
1280 1280 text_repository_identifier_info: '僅允許使用小寫英文字母 (a-z), 阿拉伯數字, 虛線與底線。<br />一旦儲存之後, 代碼便無法再次被更改。'
1281 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1282 be reassigned to an issue that is about to be deleted
@@ -1201,3 +1201,5 zh:
1201 1201 label_new_object_tab_enabled: 显示 "+" 为下拉列表
1202 1202 error_no_projects_with_tracker_allowed_for_new_issue: There are no projects with trackers
1203 1203 for which you can create an issue
1204 error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted: Spent time cannot
1205 be reassigned to an issue that is about to be deleted
@@ -4687,7 +4687,7 class IssuesControllerTest < ActionController::TestCase
4687 4687 assert_response :success
4688 4688 end
4689 4689
4690 def test_destroy_issue_with_no_time_entries
4690 def test_destroy_issue_with_no_time_entries_should_delete_the_issues
4691 4691 assert_nil TimeEntry.find_by_issue_id(2)
4692 4692 @request.session[:user_id] = 2
4693 4693
@@ -4698,7 +4698,7 class IssuesControllerTest < ActionController::TestCase
4698 4698 assert_nil Issue.find_by_id(2)
4699 4699 end
4700 4700
4701 def test_destroy_issues_with_time_entries
4701 def test_destroy_issues_with_time_entries_should_show_the_reassign_form
4702 4702 @request.session[:user_id] = 2
4703 4703
4704 4704 assert_no_difference 'Issue.count' do
@@ -4714,6 +4714,20 class IssuesControllerTest < ActionController::TestCase
4714 4714 end
4715 4715 end
4716 4716
4717 def test_destroy_issues_with_time_entries_should_show_hours_on_issues_and_descendants
4718 parent = Issue.generate_with_child!
4719 TimeEntry.generate!(:issue => parent)
4720 TimeEntry.generate!(:issue => parent.children.first)
4721 leaf = Issue.generate!
4722 TimeEntry.generate!(:issue => leaf)
4723 @request.session[:user_id] = 2
4724
4725 delete :destroy, :ids => [parent.id, leaf.id]
4726 assert_response :success
4727
4728 assert_select 'p', :text => /3\.00 hours were reported/
4729 end
4730
4717 4731 def test_destroy_issues_and_destroy_time_entries
4718 4732 @request.session[:user_id] = 2
4719 4733
@@ -4755,6 +4769,24 class IssuesControllerTest < ActionController::TestCase
4755 4769 assert_equal 2, TimeEntry.find(2).issue_id
4756 4770 end
4757 4771
4772 def test_destroy_issues_with_time_entries_should_reassign_time_entries_of_issues_and_descendants
4773 parent = Issue.generate_with_child!
4774 TimeEntry.generate!(:issue => parent)
4775 TimeEntry.generate!(:issue => parent.children.first)
4776 leaf = Issue.generate!
4777 TimeEntry.generate!(:issue => leaf)
4778 target = Issue.generate!
4779 @request.session[:user_id] = 2
4780
4781 assert_difference 'Issue.count', -3 do
4782 assert_no_difference 'TimeEntry.count' do
4783 delete :destroy, :ids => [parent.id, leaf.id], :todo => 'reassign', :reassign_to_id => target.id
4784 assert_response 302
4785 end
4786 end
4787 assert_equal 3, target.time_entries.count
4788 end
4789
4758 4790 def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail
4759 4791 @request.session[:user_id] = 2
4760 4792
@@ -4768,6 +4800,18 class IssuesControllerTest < ActionController::TestCase
4768 4800 assert_template 'destroy'
4769 4801 end
4770 4802
4803 def test_destroy_issues_and_reassign_time_entries_to_an_issue_to_delete_should_fail
4804 @request.session[:user_id] = 2
4805
4806 assert_no_difference 'Issue.count' do
4807 assert_no_difference 'TimeEntry.count' do
4808 delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 3
4809 end
4810 end
4811 assert_response :success
4812 assert_select '#flash_error', :text => I18n.t(:error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted)
4813 end
4814
4771 4815 def test_destroy_issues_from_different_projects
4772 4816 @request.session[:user_id] = 2
4773 4817
General Comments 0
You need to be logged in to leave comments. Login now