diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-03 09:57:39 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-03 09:59:22 -0700 |
commit | cb9557c432599657a8a2c1a1df50f35113c94305 (patch) | |
tree | 41b586746738431c771a5e599badd2434e311152 | |
parent | d0719c59384c387aebfdc4a78f6e985bcf5bb270 (diff) | |
download | rails-cb9557c432599657a8a2c1a1df50f35113c94305.tar.gz rails-cb9557c432599657a8a2c1a1df50f35113c94305.tar.bz2 rails-cb9557c432599657a8a2c1a1df50f35113c94305.zip |
make sure IM repository is cleared after body is closed
-rw-r--r-- | activerecord/lib/active_record/identity_map.rb | 1 | ||||
-rw-r--r-- | activerecord/test/cases/identity_map/middleware_test.rb | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/identity_map.rb b/activerecord/lib/active_record/identity_map.rb index 647f9e11d2..9eb47ad99f 100644 --- a/activerecord/lib/active_record/identity_map.rb +++ b/activerecord/lib/active_record/identity_map.rb @@ -112,6 +112,7 @@ module ActiveRecord @target.close if @target.respond_to?(:close) ensure IdentityMap.enabled = @original + IdentityMap.clear end end diff --git a/activerecord/test/cases/identity_map/middleware_test.rb b/activerecord/test/cases/identity_map/middleware_test.rb index 130f370da6..60dcad4586 100644 --- a/activerecord/test/cases/identity_map/middleware_test.rb +++ b/activerecord/test/cases/identity_map/middleware_test.rb @@ -12,6 +12,7 @@ module ActiveRecord def teardown super IdentityMap.enabled = @enabled + IdentityMap.clear end def test_delegates @@ -55,6 +56,16 @@ module ActiveRecord assert !IdentityMap.enabled?, 'identity map should be disabled' end + def test_im_cleared_after_body_close + mw = Middleware.new lambda { |env| [200, {}, []] } + body = mw.call({}).last + + IdentityMap.repository['hello'] = 'world' + assert !IdentityMap.repository.empty?, 'repo should not be empty' + + body.close + assert IdentityMap.repository.empty?, 'repo should be empty' + end end end end |