diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2010-09-01 15:09:04 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-09-01 22:32:41 +0200 |
commit | 4e67bf26aa11a59e4f513359208fe3314c5a1ba5 (patch) | |
tree | fe85848facd45aa82627651dce257831339a4e74 /activerecord/test | |
parent | f1966337fa744a1c62054120693072ebabe996a8 (diff) | |
download | rails-4e67bf26aa11a59e4f513359208fe3314c5a1ba5.tar.gz rails-4e67bf26aa11a59e4f513359208fe3314c5a1ba5.tar.bz2 rails-4e67bf26aa11a59e4f513359208fe3314c5a1ba5.zip |
Reset default scope in Thread.current when class is unloaded [#5497 state:resolved]
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 55f0b1ce21..d58e302cb2 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1415,6 +1415,21 @@ class BasicsTest < ActiveRecord::TestCase end end + def test_default_scope_is_reset + Object.const_set :UnloadablePost, Class.new(ActiveRecord::Base) + UnloadablePost.table_name = 'posts' + UnloadablePost.class_eval do + default_scope order('posts.comments_count ASC') + end + + UnloadablePost.unloadable + assert_not_nil Thread.current[:UnloadablePost_scoped_methods] + ActiveSupport::Dependencies.remove_unloadable_constants! + assert_nil Thread.current[:UnloadablePost_scoped_methods] + ensure + Object.class_eval{ remove_const :UnloadablePost } if defined?(UnloadablePost) + end + protected def with_env_tz(new_tz = 'US/Eastern') old_tz, ENV['TZ'] = ENV['TZ'], new_tz |