Use subclasses method instead of class variable.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8977 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-02-24 18:23:58 +00:00
parent 55a8087f67
commit 528735b955
2 changed files with 12 additions and 1 deletions

View File

@ -98,7 +98,7 @@ class Enumeration < ActiveRecord::Base
#
# Note: subclasses is protected in ActiveRecord
def self.get_subclasses
@@subclasses[Enumeration]
subclasses
end
# Does the +new+ Hash override the previous Enumeration?

View File

@ -108,4 +108,15 @@ class EnumerationTest < ActiveSupport::TestCase
enumeration.parent = Enumeration.find(5)
assert enumeration.is_override?
end
def test_get_subclasses
classes = Enumeration.get_subclasses
assert_include IssuePriority, classes
assert_include DocumentCategory, classes
assert_include TimeEntryActivity, classes
classes.each do |klass|
assert_equal Enumeration, klass.superclass
end
end
end