diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-10-15 23:32:31 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-10-15 23:32:31 +0000 |
commit | 497b5dcf1965dea95bc59a00214e14c42dba69cc (patch) | |
tree | 7daaea103ccfa28cd4957db153f5143cbf7cd03c /activesupport/test/dependencies_test.rb | |
parent | fa5080ae248b0043216a506ae491f52b24af27d7 (diff) | |
download | rails-497b5dcf1965dea95bc59a00214e14c42dba69cc.tar.gz rails-497b5dcf1965dea95bc59a00214e14c42dba69cc.tar.bz2 rails-497b5dcf1965dea95bc59a00214e14c42dba69cc.zip |
Add 'unloadable', a method used to mark any constant as requiring an unload after each request.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5307 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/dependencies_test.rb')
-rw-r--r-- | activesupport/test/dependencies_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index c1e95f51a9..4065625e70 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -24,6 +24,7 @@ class DependenciesTest < Test::Unit::TestCase ensure Dependencies.load_paths = prior_load_paths Dependencies.mechanism = old_mechanism + Dependencies.explicitly_unloadable_constants = [] end def test_tracking_loaded_files @@ -453,4 +454,33 @@ class DependenciesTest < Test::Unit::TestCase Object.send :remove_const, :E if Object.const_defined?(:E) end + def test_unloadable + with_loading 'autoloading_fixtures' do + Object.const_set :M, Module.new + M.unloadable + + Dependencies.clear + assert ! defined?(M) + + Object.const_set :M, Module.new + Dependencies.clear + assert ! defined?(M), "Dependencies should unload unloadable constants each time" + end + end + + def test_unloadable_should_fail_with_anonymous_modules + with_loading 'autoloading_fixtures' do + m = Module.new + assert_raises(ArgumentError) { m.unloadable } + end + end + + def test_unloadable_should_return_change_flag + with_loading 'autoloading_fixtures' do + Object.const_set :M, Module.new + assert_equal true, M.unloadable + assert_equal false, M.unloadable + end + end + end |