From 4eec5f4fbb995ce665cb82367cc3965e74147b19 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Wed, 14 Mar 2007 23:27:28 +0000 Subject: Update Dependencies to ignore constants inherited from ancestors. Closes #6951. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6426 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/module_test.rb | 8 ++++++++ activesupport/test/dependencies_test.rb | 11 +++++++++++ 2 files changed, 19 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index bbf6dd1640..884b44030c 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -1,10 +1,14 @@ require File.dirname(__FILE__) + '/../abstract_unit' module One + Constant1 = "Hello World" + Constant2 = "What's up?" end class Ab include One + Constant1 = "Hello World" # Will have different object id than One::Constant1 + Constant3 = "Goodbye World" end module Xy @@ -91,6 +95,10 @@ class ModuleTest < Test::Unit::TestCase assert_equal [Yz::Zy, Yz, Object], Yz::Zy::Cd.parents assert_equal [Yz, Object], Yz::Zy.parents end + + def test_local_constants + assert_equal %w(Constant1 Constant3), Ab.local_constants.sort + end def test_as_load_path assert_equal 'yz/zy', Yz::Zy.as_load_path diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 755cff2e3f..ad3472bddb 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -9,6 +9,10 @@ module ModuleWithMissing end end +module ModuleWithConstant + InheritedConstant = "Hello" +end + class DependenciesTest < Test::Unit::TestCase def teardown Dependencies.clear @@ -574,6 +578,13 @@ class DependenciesTest < Test::Unit::TestCase Object.send :remove_const, :M rescue nil end + def test_new_constants_in_with_inherited_constants + m = Dependencies.new_constants_in(:Object) do + Object.send :include, ModuleWithConstant + end + assert_equal [], m + end + def test_file_with_multiple_constants_and_require_dependency with_loading 'autoloading_fixtures' do assert ! defined?(MultipleConstantFile) -- cgit v1.2.3