diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-20 11:06:14 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-20 11:06:14 +0000 |
commit | 5fa66cd45c5264080a36d49c9ba803cf2fa3b51b (patch) | |
tree | 251425eddd7502ccf3f757b56f29536f0ad2259b /activesupport/test | |
parent | 8c40759b10ec6a2be2e12a9c160cb64085d490b4 (diff) | |
download | rails-5fa66cd45c5264080a36d49c9ba803cf2fa3b51b.tar.gz rails-5fa66cd45c5264080a36d49c9ba803cf2fa3b51b.tar.bz2 rails-5fa66cd45c5264080a36d49c9ba803cf2fa3b51b.zip |
Allows a loading module to load from multiple load paths #675
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@711 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/loading_module_tests.rb | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/activesupport/test/loading_module_tests.rb b/activesupport/test/loading_module_tests.rb index c1d8c7de62..b6587d48ed 100644 --- a/activesupport/test/loading_module_tests.rb +++ b/activesupport/test/loading_module_tests.rb @@ -1,12 +1,13 @@ require 'test/unit' -require '../lib/core_ext.rb' -require '../lib/dependencies.rb' +require File.dirname(__FILE__) + '/../lib/active_support/core_ext.rb' +require File.dirname(__FILE__) + '/../lib/active_support/dependencies.rb' -STAGING_DIRECTORY = 'loading_module' +STAGING_DIRECTORY = File.join(File.dirname(__FILE__), 'loading_module') +COMPONENTS_DIRECTORY = File.join(File.dirname(__FILE__), 'loading_module_components') class LoadingModuleTests < Test::Unit::TestCase def setup - @loading_module = Dependencies::LoadingModule.new(STAGING_DIRECTORY) + @loading_module = Dependencies::LoadingModule.root(STAGING_DIRECTORY) Object.const_set(:Controllers, @loading_module) end def teardown @@ -60,4 +61,27 @@ class LoadingModuleTests < Test::Unit::TestCase assert_raises(NameError) {@loading_module::PersonController} assert_raises(NameError) {@loading_module::Admin::FishController} end +end + +class LoadingModuleMultiPathTests < Test::Unit::TestCase + def setup + @loading_module = Dependencies::LoadingModule.root(STAGING_DIRECTORY, COMPONENTS_DIRECTORY) + Object.const_set(:Controllers, @loading_module) + end + def teardown + @loading_module.clear + Object.send :remove_const, :Controllers + end + + def test_access_from_first + assert_kind_of Module, @loading_module::Admin + assert_kind_of Dependencies::LoadingModule, @loading_module::Admin + assert_kind_of Class, @loading_module::Admin::UserController + end + def test_access_from_second + assert_kind_of Module, @loading_module::List + assert_kind_of Dependencies::LoadingModule, @loading_module::List + assert @loading_module::List.const_load! :ListController + assert_kind_of Class, @loading_module::List::ListController + end end
\ No newline at end of file |