diff options
author | José Valim <jose.valim@gmail.com> | 2010-07-05 12:50:08 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-05 13:01:27 +0200 |
commit | a5dda97602f2188a13cbcab5c7e9a5ba84ba876b (patch) | |
tree | be84ca4360059f6eb3f696b46e1bdad3d57b1ce2 /activesupport/test/descendants_tracker_test.rb | |
parent | 5bf3294c8b3aeb3afd426e8c182456c675829c1e (diff) | |
download | rails-a5dda97602f2188a13cbcab5c7e9a5ba84ba876b.tar.gz rails-a5dda97602f2188a13cbcab5c7e9a5ba84ba876b.tar.bz2 rails-a5dda97602f2188a13cbcab5c7e9a5ba84ba876b.zip |
Define a convention for descendants and subclasses.
The former should be symmetric with ancestors and include all children. However, it should not include self since ancestors + descendants should not have duplicated. The latter is symmetric to superclass in the sense it only includes direct children.
By adopting a convention, we expect to have less conflict with other frameworks, as Datamapper. For this moment, to ensure ActiveModel::Validations can be used with Datamapper, we should always call ActiveSupport::DescendantsTracker.descendants(self) internally instead of self.descendants avoiding conflicts.
Diffstat (limited to 'activesupport/test/descendants_tracker_test.rb')
-rw-r--r-- | activesupport/test/descendants_tracker_test.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/test/descendants_tracker_test.rb b/activesupport/test/descendants_tracker_test.rb index ff24e310de..79fb893592 100644 --- a/activesupport/test/descendants_tracker_test.rb +++ b/activesupport/test/descendants_tracker_test.rb @@ -37,7 +37,9 @@ class DescendantsTrackerTest < Test::Unit::TestCase def test_clear_with_autoloaded_parent_children_and_granchildren mark_as_autoloaded(*ALL) do ActiveSupport::DescendantsTracker.clear - assert ActiveSupport::DescendantsTracker.descendants.slice(*ALL).empty? + ALL.each do |k| + assert ActiveSupport::DescendantsTracker.descendants(k).empty? + end end end @@ -64,12 +66,12 @@ class DescendantsTrackerTest < Test::Unit::TestCase old_autoloaded = ActiveSupport::Dependencies.autoloaded_constants.dup ActiveSupport::Dependencies.autoloaded_constants = klasses.map(&:name) - old_descendants = ActiveSupport::DescendantsTracker.descendants.dup + old_descendants = ActiveSupport::DescendantsTracker.class_eval("@@direct_descendants").dup old_descendants.each { |k, v| old_descendants[k] = v.dup } yield ensure ActiveSupport::Dependencies.autoloaded_constants = old_autoloaded - ActiveSupport::DescendantsTracker.descendants.replace(old_descendants) + ActiveSupport::DescendantsTracker.class_eval("@@direct_descendants").replace(old_descendants) end end
\ No newline at end of file |