##// END OF EJS Templates
Let the user choose when deleting issues with reported hours (closes #734, #71):...
Jean-Philippe Lang -
r1168:c01c64e9783d
parent child
Show More
@@ -0,0 +1,15
1 <h2><%= l(:confirmation) %></h2>
2
3 <% form_tag do %>
4 <%= @issues.collect {|i| hidden_field_tag 'ids[]', i.id } %>
5 <div class="box">
6 <p><strong><%= l(:text_destroy_time_entries_question, @hours) %></strong></p>
7 <p>
8 <label><%= radio_button_tag 'todo', 'destroy', true %> <%= l(:text_destroy_time_entries) %></label><br />
9 <label><%= radio_button_tag 'todo', 'nullify', false %> <%= l(:text_assign_time_entries_to_project) %></label><br />
10 <label><%= radio_button_tag 'todo', 'reassign', false, :onchange => 'if (this.checked) { $("reassign_to_id").focus(); }' %> <%= l(:text_reassign_time_entries) %></label>
11 <%= text_field_tag 'reassign_to_id', params[:reassign_to_id], :size => 6, :onfocus => '$("todo_reassign").checked=true;' %>
12 </p>
13 </div>
14 <%= submit_tag l(:button_apply) %>
15 <% end %>
@@ -263,6 +263,26 class IssuesController < ApplicationController
263 end
263 end
264
264
265 def destroy
265 def destroy
266 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
267 if @hours > 0
268 case params[:todo]
269 when 'destroy'
270 # nothing to do
271 when 'nullify'
272 TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
273 when 'reassign'
274 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
275 if reassign_to.nil?
276 flash.now[:error] = l(:error_issue_not_found_in_project)
277 return
278 else
279 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
280 end
281 else
282 # display the destroy form
283 return
284 end
285 end
266 @issues.each(&:destroy)
286 @issues.each(&:destroy)
267 redirect_to :action => 'index', :project_id => @project
287 redirect_to :action => 'index', :project_id => @project
268 end
288 end
@@ -27,7 +27,7 class Issue < ActiveRecord::Base
27
27
28 has_many :journals, :as => :journalized, :dependent => :destroy
28 has_many :journals, :as => :journalized, :dependent => :destroy
29 has_many :attachments, :as => :container, :dependent => :destroy
29 has_many :attachments, :as => :container, :dependent => :destroy
30 has_many :time_entries, :dependent => :nullify
30 has_many :time_entries, :dependent => :delete_all
31 has_many :custom_values, :dependent => :delete_all, :as => :customized
31 has_many :custom_values, :dependent => :delete_all, :as => :customized
32 has_many :custom_fields, :through => :custom_values
32 has_many :custom_fields, :through => :custom_values
33 has_and_belongs_to_many :changesets, :order => "revision ASC"
33 has_and_belongs_to_many :changesets, :order => "revision ASC"
@@ -3,9 +3,9
3 <% form_tag({}) do %>
3 <% form_tag({}) do %>
4 <div class="box">
4 <div class="box">
5 <p><strong><%= l(:text_issue_category_destroy_question, @issue_count) %></strong></p>
5 <p><strong><%= l(:text_issue_category_destroy_question, @issue_count) %></strong></p>
6 <p><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_issue_category_destroy_assignments) %><br />
6 <p><label><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_issue_category_destroy_assignments) %></label><br />
7 <% if @categories.size > 0 %>
7 <% if @categories.size > 0 %>
8 <%= radio_button_tag 'todo', 'reassign', false %> <%= l(:text_issue_category_reassign_to) %>:
8 <label><%= radio_button_tag 'todo', 'reassign', false %> <%= l(:text_issue_category_reassign_to) %></label>:
9 <%= select_tag 'reassign_to_id', options_from_collection_for_select(@categories, 'id', 'name') %></p>
9 <%= select_tag 'reassign_to_id', options_from_collection_for_select(@categories, 'id', 'name') %></p>
10 <% end %>
10 <% end %>
11 </div>
11 </div>
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -80,6 +80,7 notice_default_data_loaded: Default configuration successfully loaded.
80 error_can_t_load_default_data: "Default configuration could not be loaded: %s"
80 error_can_t_load_default_data: "Default configuration could not be loaded: %s"
81 error_scm_not_found: "Entry and/or revision doesn't exist in the repository."
81 error_scm_not_found: "Entry and/or revision doesn't exist in the repository."
82 error_scm_command_failed: "An error occurred when trying to access the repository: %s"
82 error_scm_command_failed: "An error occurred when trying to access the repository: %s"
83 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
83
84
84 mail_subject_lost_password: Your Redmine password
85 mail_subject_lost_password: Your Redmine password
85 mail_body_lost_password: 'To change your Redmine password, click on the following link:'
86 mail_body_lost_password: 'To change your Redmine password, click on the following link:'
@@ -577,6 +578,10 text_select_project_modules: 'Select modules to enable for this project:'
577 text_default_administrator_account_changed: Default administrator account changed
578 text_default_administrator_account_changed: Default administrator account changed
578 text_file_repository_writable: File repository writable
579 text_file_repository_writable: File repository writable
579 text_rmagick_available: RMagick available (optional)
580 text_rmagick_available: RMagick available (optional)
581 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
582 text_destroy_time_entries: Delete reported hours
583 text_assign_time_entries_to_project: Assign reported hours to the project
584 text_reassign_time_entries: 'Reassign reported hours to this issue:'
580
585
581 default_role_manager: Manager
586 default_role_manager: Manager
582 default_role_developper: Developer
587 default_role_developper: Developer
@@ -605,3 +605,8 label_yesterday: yesterday
605 label_last_month: last month
605 label_last_month: last month
606 label_add_another_file: Add another file
606 label_add_another_file: Add another file
607 label_optional_description: Optional description
607 label_optional_description: Optional description
608 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
609 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
610 text_assign_time_entries_to_project: Assign reported hours to the project
611 text_destroy_time_entries: Delete reported hours
612 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -606,3 +606,8 label_yesterday: yesterday
606 label_last_month: last month
606 label_last_month: last month
607 label_add_another_file: Add another file
607 label_add_another_file: Add another file
608 label_optional_description: Optional description
608 label_optional_description: Optional description
609 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
610 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
611 text_assign_time_entries_to_project: Assign reported hours to the project
612 text_destroy_time_entries: Delete reported hours
613 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -80,6 +80,7 notice_default_data_loaded: Paramétrage par défaut chargé avec succès.
80 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage: %s"
80 error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage: %s"
81 error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
81 error_scm_not_found: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
82 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt: %s"
82 error_scm_command_failed: "Une erreur s'est produite lors de l'accès au dépôt: %s"
83 error_issue_not_found_in_project: "La demande n'existe pas ou n'appartient pas à ce projet"
83
84
84 mail_subject_lost_password: Votre mot de passe redMine
85 mail_subject_lost_password: Votre mot de passe redMine
85 mail_body_lost_password: 'Pour changer votre mot de passe Redmine, cliquez sur le lien suivant:'
86 mail_body_lost_password: 'Pour changer votre mot de passe Redmine, cliquez sur le lien suivant:'
@@ -565,7 +566,7 text_issues_ref_in_commit_messages: Référencement et résolution des demandes
565 text_issue_added: La demande %s a été soumise par %s.
566 text_issue_added: La demande %s a été soumise par %s.
566 text_issue_updated: La demande %s a été mise à jour par %s.
567 text_issue_updated: La demande %s a été mise à jour par %s.
567 text_wiki_destroy_confirmation: Etes-vous sûr de vouloir supprimer ce wiki et tout son contenu ?
568 text_wiki_destroy_confirmation: Etes-vous sûr de vouloir supprimer ce wiki et tout son contenu ?
568 text_issue_category_destroy_question: Des demandes (%d) sont affectées à cette catégories. Que voulez-vous faire ?
569 text_issue_category_destroy_question: %d demandes sont affectées à cette catégories. Que voulez-vous faire ?
569 text_issue_category_destroy_assignments: N'affecter les demandes à aucune autre catégorie
570 text_issue_category_destroy_assignments: N'affecter les demandes à aucune autre catégorie
570 text_issue_category_reassign_to: Réaffecter les demandes à cette catégorie
571 text_issue_category_reassign_to: Réaffecter les demandes à cette catégorie
571 text_user_mail_option: "Pour les projets non sélectionnés, vous recevrez seulement des notifications pour ce que vous surveillez ou à quoi vous participez (exemple: demandes dont vous êtes l'auteur ou la personne assignée)."
572 text_user_mail_option: "Pour les projets non sélectionnés, vous recevrez seulement des notifications pour ce que vous surveillez ou à quoi vous participez (exemple: demandes dont vous êtes l'auteur ou la personne assignée)."
@@ -577,6 +578,10 text_select_project_modules: 'Selectionner les modules à activer pour ce projec
577 text_default_administrator_account_changed: Compte administrateur par défaut changé
578 text_default_administrator_account_changed: Compte administrateur par défaut changé
578 text_file_repository_writable: Répertoire de stockage des fichiers accessible en écriture
579 text_file_repository_writable: Répertoire de stockage des fichiers accessible en écriture
579 text_rmagick_available: Bibliothèque RMagick présente (optionnelle)
580 text_rmagick_available: Bibliothèque RMagick présente (optionnelle)
581 text_destroy_time_entries_question: %.02f heures ont été enregistrées sur les demandes à supprimer. Que voulez-vous faire ?
582 text_destroy_time_entries: Supprimer les heures
583 text_assign_time_entries_to_project: Reporter les heures sur le projet
584 text_reassign_time_entries: 'Reporter les heures sur cette demande:'
580
585
581 default_role_manager: Manager
586 default_role_manager: Manager
582 default_role_developper: Développeur
587 default_role_developper: Développeur
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -603,3 +603,8 label_yesterday: yesterday
603 label_last_month: last month
603 label_last_month: last month
604 label_add_another_file: Add another file
604 label_add_another_file: Add another file
605 label_optional_description: Optional description
605 label_optional_description: Optional description
606 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
607 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
608 text_assign_time_entries_to_project: Assign reported hours to the project
609 text_destroy_time_entries: Delete reported hours
610 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -603,3 +603,8 label_yesterday: yesterday
603 label_last_month: last month
603 label_last_month: last month
604 label_add_another_file: Add another file
604 label_add_another_file: Add another file
605 label_optional_description: Optional description
605 label_optional_description: Optional description
606 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
607 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
608 text_assign_time_entries_to_project: Assign reported hours to the project
609 text_destroy_time_entries: Delete reported hours
610 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -603,3 +603,8 label_yesterday: yesterday
603 label_last_month: last month
603 label_last_month: last month
604 label_add_another_file: Add another file
604 label_add_another_file: Add another file
605 label_optional_description: Optional description
605 label_optional_description: Optional description
606 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
607 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
608 text_assign_time_entries_to_project: Assign reported hours to the project
609 text_destroy_time_entries: Delete reported hours
610 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -606,3 +606,8 label_yesterday: yesterday
606 label_last_month: last month
606 label_last_month: last month
607 label_add_another_file: Add another file
607 label_add_another_file: Add another file
608 label_optional_description: Optional description
608 label_optional_description: Optional description
609 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
610 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
611 text_assign_time_entries_to_project: Assign reported hours to the project
612 text_destroy_time_entries: Delete reported hours
613 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -603,3 +603,8 label_yesterday: yesterday
603 label_last_month: last month
603 label_last_month: last month
604 label_add_another_file: Add another file
604 label_add_another_file: Add another file
605 label_optional_description: Optional description
605 label_optional_description: Optional description
606 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
607 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
608 text_assign_time_entries_to_project: Assign reported hours to the project
609 text_destroy_time_entries: Delete reported hours
610 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -603,3 +603,8 label_yesterday: yesterday
603 label_last_month: last month
603 label_last_month: last month
604 label_add_another_file: Add another file
604 label_add_another_file: Add another file
605 label_optional_description: Optional description
605 label_optional_description: Optional description
606 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
607 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
608 text_assign_time_entries_to_project: Assign reported hours to the project
609 text_destroy_time_entries: Delete reported hours
610 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -604,3 +604,8 label_yesterday: yesterday
604 label_last_month: last month
604 label_last_month: last month
605 label_add_another_file: Add another file
605 label_add_another_file: Add another file
606 label_optional_description: Optional description
606 label_optional_description: Optional description
607 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
608 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
609 text_assign_time_entries_to_project: Assign reported hours to the project
610 text_destroy_time_entries: Delete reported hours
611 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -602,3 +602,8 label_yesterday: yesterday
602 label_last_month: last month
602 label_last_month: last month
603 label_add_another_file: Add another file
603 label_add_another_file: Add another file
604 label_optional_description: Optional description
604 label_optional_description: Optional description
605 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
606 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
607 text_assign_time_entries_to_project: Assign reported hours to the project
608 text_destroy_time_entries: Delete reported hours
609 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -605,3 +605,8 label_yesterday: yesterday
605 label_last_month: last month
605 label_last_month: last month
606 label_add_another_file: Add another file
606 label_add_another_file: Add another file
607 label_optional_description: Optional description
607 label_optional_description: Optional description
608 text_destroy_time_entries_question: %.02f hours were reported on the issues you are about to delete. What do you want to do ?
609 error_issue_not_found_in_project: 'The issue was not found or does not belong to this project'
610 text_assign_time_entries_to_project: Assign reported hours to the project
611 text_destroy_time_entries: Delete reported hours
612 text_reassign_time_entries: 'Reassign reported hours to this issue:'
@@ -37,7 +37,8 class IssuesControllerTest < Test::Unit::TestCase
37 :workflows,
37 :workflows,
38 :custom_fields,
38 :custom_fields,
39 :custom_values,
39 :custom_values,
40 :custom_fields_trackers
40 :custom_fields_trackers,
41 :time_entries
41
42
42 def setup
43 def setup
43 @controller = IssuesController.new
44 @controller = IssuesController.new
@@ -428,13 +429,48 class IssuesControllerTest < Test::Unit::TestCase
428 :class => 'icon-del disabled' }
429 :class => 'icon-del disabled' }
429 end
430 end
430
431
431 def test_destroy
432 def test_destroy_issue_with_no_time_entries
432 @request.session[:user_id] = 2
433 @request.session[:user_id] = 2
433 post :destroy, :id => 1
434 post :destroy, :id => 3
434 assert_redirected_to 'projects/ecookbook/issues'
435 assert_redirected_to 'projects/ecookbook/issues'
435 assert_nil Issue.find_by_id(1)
436 assert_nil Issue.find_by_id(3)
436 end
437 end
437
438
439 def test_destroy_issues_with_time_entries
440 @request.session[:user_id] = 2
441 post :destroy, :ids => [1, 3]
442 assert_response :success
443 assert_template 'destroy'
444 assert_not_nil assigns(:hours)
445 assert Issue.find_by_id(1) && Issue.find_by_id(3)
446 end
447
448 def test_destroy_issues_and_destroy_time_entries
449 @request.session[:user_id] = 2
450 post :destroy, :ids => [1, 3], :todo => 'destroy'
451 assert_redirected_to 'projects/ecookbook/issues'
452 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
453 assert_nil TimeEntry.find_by_id([1, 2])
454 end
455
456 def test_destroy_issues_and_assign_time_entries_to_project
457 @request.session[:user_id] = 2
458 post :destroy, :ids => [1, 3], :todo => 'nullify'
459 assert_redirected_to 'projects/ecookbook/issues'
460 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
461 assert_nil TimeEntry.find(1).issue_id
462 assert_nil TimeEntry.find(2).issue_id
463 end
464
465 def test_destroy_issues_and_reassign_time_entries_to_another_issue
466 @request.session[:user_id] = 2
467 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
468 assert_redirected_to 'projects/ecookbook/issues'
469 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
470 assert_equal 2, TimeEntry.find(1).issue_id
471 assert_equal 2, TimeEntry.find(2).issue_id
472 end
473
438 def test_destroy_attachment
474 def test_destroy_attachment
439 issue = Issue.find(3)
475 issue = Issue.find(3)
440 a = issue.attachments.size
476 a = issue.attachments.size
@@ -70,4 +70,10 class IssueTest < Test::Unit::TestCase
70 # Make sure time entries were move to the target project
70 # Make sure time entries were move to the target project
71 assert_equal 2, issue.time_entries.first.project_id
71 assert_equal 2, issue.time_entries.first.project_id
72 end
72 end
73
74 def test_issue_destroy
75 Issue.find(1).destroy
76 assert_nil Issue.find_by_id(1)
77 assert_nil TimeEntry.find_by_issue_id(1)
78 end
73 end
79 end
General Comments 0
You need to be logged in to leave comments. Login now