From 3c95f761e610a1d5957ca9f96708958ba80565ab Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 17 Jun 2008 19:10:54 +0000 Subject: [PATCH] Ability to remove enumerations (activities, priorities, document categories) that are in use. Associated objects can be reassigned to another value (#1467). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1558 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/enumerations_controller.rb | 21 +++++--- app/models/enumeration.rb | 37 ++++++++----- app/views/enumerations/destroy.rhtml | 12 +++++ app/views/enumerations/list.rhtml | 7 ++- lang/bg.yml | 2 + lang/cs.yml | 2 + lang/da.yml | 2 + lang/de.yml | 2 + lang/en.yml | 2 + lang/es.yml | 2 + lang/fi.yml | 2 + lang/fr.yml | 2 + lang/he.yml | 2 + lang/hu.yml | 2 + lang/it.yml | 2 + lang/ja.yml | 2 + lang/ko.yml | 2 + lang/lt.yml | 2 + lang/nl.yml | 2 + lang/no.yml | 2 + lang/pl.yml | 2 + lang/pt-br.yml | 2 + lang/pt.yml | 2 + lang/ro.yml | 2 + lang/ru.yml | 2 + lang/sr.yml | 2 + lang/sv.yml | 2 + lang/th.yml | 2 + lang/uk.yml | 2 + lang/zh-tw.yml | 2 + lang/zh.yml | 2 + test/functional/enumerations_controller.rb | 61 ++++++++++++++++++++++ test/unit/enumeration_test.rb | 45 ++++++++++++++++ 33 files changed, 217 insertions(+), 20 deletions(-) create mode 100644 app/views/enumerations/destroy.rhtml create mode 100644 test/functional/enumerations_controller.rb create mode 100644 test/unit/enumeration_test.rb diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rb index 7a7f1685a..788fa11b2 100644 --- a/app/controllers/enumerations_controller.rb +++ b/app/controllers/enumerations_controller.rb @@ -75,11 +75,20 @@ class EnumerationsController < ApplicationController end def destroy - Enumeration.find(params[:id]).destroy - flash[:notice] = l(:notice_successful_delete) - redirect_to :action => 'list' - rescue - flash[:error] = "Unable to delete enumeration" - redirect_to :action => 'list' + @enumeration = Enumeration.find(params[:id]) + if !@enumeration.in_use? + # No associated objects + @enumeration.destroy + redirect_to :action => 'index' + elsif params[:reassign_to_id] + if reassign_to = Enumeration.find_by_opt_and_id(@enumeration.opt, params[:reassign_to_id]) + @enumeration.destroy(reassign_to) + redirect_to :action => 'index' + end + end + @enumerations = Enumeration.get_values(@enumeration.opt) - [@enumeration] + #rescue + # flash[:error] = 'Unable to delete enumeration' + # redirect_to :action => 'index' end end diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index e86768724..d32a0c049 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -24,10 +24,11 @@ class Enumeration < ActiveRecord::Base validates_uniqueness_of :name, :scope => [:opt] validates_length_of :name, :maximum => 30 + # Single table inheritance would be an option OPTIONS = { - "IPRI" => :enumeration_issue_priorities, - "DCAT" => :enumeration_doc_categories, - "ACTI" => :enumeration_activities + "IPRI" => {:label => :enumeration_issue_priorities, :model => Issue, :foreign_key => :priority_id}, + "DCAT" => {:label => :enumeration_doc_categories, :model => Document, :foreign_key => :category_id}, + "ACTI" => {:label => :enumeration_activities, :model => TimeEntry, :foreign_key => :activity_id} }.freeze def self.get_values(option) @@ -39,13 +40,32 @@ class Enumeration < ActiveRecord::Base end def option_name - OPTIONS[self.opt] + OPTIONS[self.opt][:label] end def before_save Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt}) if is_default? end + def objects_count + OPTIONS[self.opt][:model].count(:conditions => "#{OPTIONS[self.opt][:foreign_key]} = #{id}") + end + + def in_use? + self.objects_count != 0 + end + + alias :destroy_without_reassign :destroy + + # Destroy the enumeration + # If a enumeration is specified, objects are reassigned + def destroy(reassign_to = nil) + if reassign_to && reassign_to.is_a?(Enumeration) + OPTIONS[self.opt][:model].update_all("#{OPTIONS[self.opt][:foreign_key]} = #{reassign_to.id}", "#{OPTIONS[self.opt][:foreign_key]} = #{id}") + end + destroy_without_reassign + end + def <=>(enumeration) position <=> enumeration.position end @@ -54,13 +74,6 @@ class Enumeration < ActiveRecord::Base private def check_integrity - case self.opt - when "IPRI" - raise "Can't delete enumeration" if Issue.find(:first, :conditions => ["priority_id=?", self.id]) - when "DCAT" - raise "Can't delete enumeration" if Document.find(:first, :conditions => ["category_id=?", self.id]) - when "ACTI" - raise "Can't delete enumeration" if TimeEntry.find(:first, :conditions => ["activity_id=?", self.id]) - end + raise "Can't delete enumeration" if self.in_use? end end diff --git a/app/views/enumerations/destroy.rhtml b/app/views/enumerations/destroy.rhtml new file mode 100644 index 000000000..657df8322 --- /dev/null +++ b/app/views/enumerations/destroy.rhtml @@ -0,0 +1,12 @@ +

<%= l(@enumeration.option_name) %>: <%=h @enumeration %>

+ +<% form_tag({}) do %> +
+

<%= l(:text_enumeration_destroy_question, @enumeration.objects_count) %>

+

<%= l(:text_enumeration_category_reassign_to) %> +<%= select_tag 'reassign_to_id', ("" + options_from_collection_for_select(@enumerations, 'id', 'name')) %>

+
+ +<%= submit_tag l(:button_apply) %> +<%= link_to l(:button_cancel), :controller => 'enumerations', :action => 'index' %> +<% end %> diff --git a/app/views/enumerations/list.rhtml b/app/views/enumerations/list.rhtml index 1967e5cf9..7f3886b44 100644 --- a/app/views/enumerations/list.rhtml +++ b/app/views/enumerations/list.rhtml @@ -1,7 +1,7 @@

<%=l(:label_enumerations)%>

-<% Enumeration::OPTIONS.each do |option, name| %> -

<%= l(name) %>

+<% Enumeration::OPTIONS.each do |option, params| %> +

<%= l(params[:label]) %>

<% enumerations = Enumeration.get_values(option) %> <% if enumerations.any? %> @@ -16,6 +16,9 @@ <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => enumeration, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %> <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => enumeration, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %> + + <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, :method => :post, :confirm => l(:text_are_you_sure), :class => "icon icon-del" %> + <% end %> diff --git a/lang/bg.yml b/lang/bg.yml index 5f3548684..48226c79a 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/cs.yml b/lang/cs.yml index 26e0f5131..de460ba3a 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -629,3 +629,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/da.yml b/lang/da.yml index b2f18db4c..6919cdfcb 100644 --- a/lang/da.yml +++ b/lang/da.yml @@ -626,3 +626,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/de.yml b/lang/de.yml index 1e4040f3d..290acd916 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -625,3 +625,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/en.yml b/lang/en.yml index b7f217e6c..ffbd10622 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -599,6 +599,8 @@ text_destroy_time_entries: Delete reported hours text_assign_time_entries_to_project: Assign reported hours to the project text_reassign_time_entries: 'Reassign reported hours to this issue:' text_user_wrote: '%s wrote:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' +text_enumeration_category_reassign_to: 'Reassign them to this value:' default_role_manager: Manager default_role_developper: Developer diff --git a/lang/es.yml b/lang/es.yml index c0ecb997b..b027f48e3 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -627,3 +627,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/fi.yml b/lang/fi.yml index 6ac4aea7e..e1d188dcc 100644 --- a/lang/fi.yml +++ b/lang/fi.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/fr.yml b/lang/fr.yml index 4db2f8f3a..eaae51765 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -599,6 +599,8 @@ text_destroy_time_entries: Supprimer les heures text_assign_time_entries_to_project: Reporter les heures sur le projet text_reassign_time_entries: 'Reporter les heures sur cette demande:' text_user_wrote: '%s a écrit:' +text_enumeration_destroy_question: 'Cette valeur est affectée à %d objets.' +text_enumeration_category_reassign_to: 'Réaffecter les objets à cette valeur:' default_role_manager: Manager default_role_developper: Développeur diff --git a/lang/he.yml b/lang/he.yml index e23698d32..5f14ee16e 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/hu.yml b/lang/hu.yml index 1df061942..c46d0e26c 100644 --- a/lang/hu.yml +++ b/lang/hu.yml @@ -625,3 +625,5 @@ mail_subject_reminder: "%d feladat határidős az elkövetkező napokban" text_user_wrote: '%s írta:' label_duplicated_by: duplikálta setting_enabled_scm: Forráskódkezelő (SCM) engedélyezése +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/it.yml b/lang/it.yml index 5ab9ad310..8aec9ef0e 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/ja.yml b/lang/ja.yml index c693d68e5..c48579dda 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -625,3 +625,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/ko.yml b/lang/ko.yml index af1c768af..f2339556f 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/lt.yml b/lang/lt.yml index ff8f6b695..61533b3ab 100644 --- a/lang/lt.yml +++ b/lang/lt.yml @@ -626,3 +626,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/nl.yml b/lang/nl.yml index 9ee913848..109d444f1 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -625,3 +625,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/no.yml b/lang/no.yml index aa9d0396b..4e47c75a2 100644 --- a/lang/no.yml +++ b/lang/no.yml @@ -625,3 +625,5 @@ default_activity_development: Utvikling enumeration_issue_priorities: Sakssprioriteringer enumeration_doc_categories: Dokument-kategorier enumeration_activities: Aktiviteter (tidssporing) +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/pl.yml b/lang/pl.yml index 75e04ecd4..97378b5b1 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/pt-br.yml b/lang/pt-br.yml index dabab5bfe..67822499e 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/pt.yml b/lang/pt.yml index 2845f390c..a91eea01b 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/ro.yml b/lang/ro.yml index dd51e59be..aafc61916 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -624,3 +624,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/ru.yml b/lang/ru.yml index c3ec91897..e04377781 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -628,3 +628,5 @@ mail_subject_reminder: "%d назначенных на вас задач в бл text_user_wrote: '%s написал:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/sr.yml b/lang/sr.yml index 92906760b..ec01774bc 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -625,3 +625,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/sv.yml b/lang/sv.yml index f08e45eb0..e28943d9b 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -625,3 +625,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/th.yml b/lang/th.yml index 85a1f8c01..6c84dba70 100644 --- a/lang/th.yml +++ b/lang/th.yml @@ -627,3 +627,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/uk.yml b/lang/uk.yml index ae8c5cbc0..365ced150 100644 --- a/lang/uk.yml +++ b/lang/uk.yml @@ -626,3 +626,5 @@ mail_subject_reminder: "%d issue(s) due in the next days" text_user_wrote: '%s wrote:' label_duplicated_by: duplicated by setting_enabled_scm: Enabled SCM +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index 064004c3a..c7b473548 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -625,3 +625,5 @@ default_activity_development: 開發 enumeration_issue_priorities: 項目優先權 enumeration_doc_categories: 文件分類 enumeration_activities: 活動 (時間追蹤) +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/lang/zh.yml b/lang/zh.yml index ac650c853..981e8102d 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -625,3 +625,5 @@ default_activity_development: 开发 enumeration_issue_priorities: 问题优先级 enumeration_doc_categories: 文档类别 enumeration_activities: 活动(时间跟踪) +text_enumeration_category_reassign_to: 'Reassign them to this value:' +text_enumeration_destroy_question: '%d objects are assigned to this value.' diff --git a/test/functional/enumerations_controller.rb b/test/functional/enumerations_controller.rb new file mode 100644 index 000000000..36ff86720 --- /dev/null +++ b/test/functional/enumerations_controller.rb @@ -0,0 +1,61 @@ +# redMine - project management software +# Copyright (C) 2006-2008 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.dirname(__FILE__) + '/../test_helper' +require 'enumerations_controller' + +# Re-raise errors caught by the controller. +class EnumerationsController; def rescue_action(e) raise e end; end + +class EnumerationsControllerTest < Test::Unit::TestCase + fixtures :enumerations, :issues, :users + + def setup + @controller = EnumerationsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + @request.session[:user_id] = 1 # admin + end + + def test_index + get :index + assert_response :success + assert_template 'list' + end + + def test_destroy_enumeration_not_in_use + post :destroy, :id => 7 + assert_redirected_to :controller => 'enumerations', :action => 'index' + assert_nil Enumeration.find_by_id(7) + end + + def test_destroy_enumeration_in_use + post :destroy, :id => 4 + assert_response :success + assert_template 'destroy' + assert_not_nil Enumeration.find_by_id(4) + end + + def test_destroy_enumeration_in_use_with_reassignment + issue = Issue.find(:first, :conditions => {:priority_id => 4}) + post :destroy, :id => 4, :reassign_to_id => 6 + assert_redirected_to :controller => 'enumerations', :action => 'index' + assert_nil Enumeration.find_by_id(4) + # check that the issue was reassign + assert_equal 6, issue.reload.priority_id + end +end diff --git a/test/unit/enumeration_test.rb b/test/unit/enumeration_test.rb new file mode 100644 index 000000000..9b7bfd174 --- /dev/null +++ b/test/unit/enumeration_test.rb @@ -0,0 +1,45 @@ +# redMine - project management software +# Copyright (C) 2006-2008 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.dirname(__FILE__) + '/../test_helper' + +class EnumerationTest < Test::Unit::TestCase + fixtures :enumerations, :issues + + def setup + end + + def test_objects_count + # low priority + assert_equal 5, Enumeration.find(4).objects_count + # urgent + assert_equal 0, Enumeration.find(7).objects_count + end + + def test_in_use + # low priority + assert Enumeration.find(4).in_use? + # urgent + assert !Enumeration.find(7).in_use? + end + + def test_destroy_with_reassign + Enumeration.find(4).destroy(Enumeration.find(6)) + assert_nil Issue.find(:first, :conditions => {:priority_id => 4}) + assert_equal 5, Enumeration.find(6).objects_count + end +end -- 2.39.5