diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-05-05 10:13:33 -0400 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-05-19 15:47:35 +0100 |
commit | eb09411460d11c7b1b1b54272ba345a1e1cf472d (patch) | |
tree | aead0864ec29f63235c90e203c7db484f0d2d6b6 /activesupport/test | |
parent | 99e9a733c8852f4ff065f2ede9c9cd03475411a2 (diff) | |
download | rails-eb09411460d11c7b1b1b54272ba345a1e1cf472d.tar.gz rails-eb09411460d11c7b1b1b54272ba345a1e1cf472d.tar.bz2 rails-eb09411460d11c7b1b1b54272ba345a1e1cf472d.zip |
Fix constantize so top level constants are looked up properly.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/constantize_test_cases.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activesupport/test/constantize_test_cases.rb b/activesupport/test/constantize_test_cases.rb index 908f9e9a37..470213e9bd 100644 --- a/activesupport/test/constantize_test_cases.rb +++ b/activesupport/test/constantize_test_cases.rb @@ -12,6 +12,16 @@ module Ace end end +class Object + module AddtlGlobalConstants + class Case + class Dice + end + end + end + include AddtlGlobalConstants +end + module ConstantizeTestCases def run_constantize_tests_on assert_nothing_raised { assert_equal Ace::Base::Case, yield("Ace::Base::Case") } @@ -19,8 +29,12 @@ module ConstantizeTestCases assert_nothing_raised { assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice") } assert_nothing_raised { assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice") } assert_nothing_raised { assert_equal Ace::Gas::Case, yield("Ace::Gas::Case") } + assert_nothing_raised { assert_equal Case::Dice, yield("Case::Dice") } + assert_nothing_raised { assert_equal Case::Dice, yield("Object::Case::Dice") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") } + assert_nothing_raised { assert_equal Object, yield("") } + assert_nothing_raised { assert_equal Object, yield("::") } assert_raise(NameError) { yield("UnknownClass") } assert_raise(NameError) { yield("UnknownClass::Ace") } assert_raise(NameError) { yield("UnknownClass::Ace::Base") } @@ -38,8 +52,12 @@ module ConstantizeTestCases assert_nothing_raised { assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice") } assert_nothing_raised { assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice") } assert_nothing_raised { assert_equal Ace::Gas::Case, yield("Ace::Gas::Case") } + assert_nothing_raised { assert_equal Case::Dice, yield("Case::Dice") } + assert_nothing_raised { assert_equal Case::Dice, yield("Object::Case::Dice") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") } + assert_nothing_raised { assert_equal Object, yield("") } + assert_nothing_raised { assert_equal Object, yield("::") } assert_nothing_raised { assert_equal nil, yield("UnknownClass") } assert_nothing_raised { assert_equal nil, yield("UnknownClass::Ace") } assert_nothing_raised { assert_equal nil, yield("UnknownClass::Ace::Base") } |