aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2007-03-14 23:27:28 +0000
committerNicholas Seckar <nseckar@gmail.com>2007-03-14 23:27:28 +0000
commit4eec5f4fbb995ce665cb82367cc3965e74147b19 (patch)
treeb44ff95dc30372057dc47699423bad0c35c0a4b0 /activesupport/test
parentbbcfb9b625c4ed471fcf7c827b700ccb025e7dd9 (diff)
downloadrails-4eec5f4fbb995ce665cb82367cc3965e74147b19.tar.gz
rails-4eec5f4fbb995ce665cb82367cc3965e74147b19.tar.bz2
rails-4eec5f4fbb995ce665cb82367cc3965e74147b19.zip
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
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/module_test.rb8
-rw-r--r--activesupport/test/dependencies_test.rb11
2 files changed, 19 insertions, 0 deletions
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)