1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

make sure IM repository is cleared after body is closed

This commit is contained in:
Aaron Patterson 2011-05-03 09:57:39 -07:00
parent d0719c5938
commit cb9557c432
2 changed files with 12 additions and 0 deletions

View file

@ -112,6 +112,7 @@ module ActiveRecord
@target.close if @target.respond_to?(:close) @target.close if @target.respond_to?(:close)
ensure ensure
IdentityMap.enabled = @original IdentityMap.enabled = @original
IdentityMap.clear
end end
end end

View file

@ -12,6 +12,7 @@ module ActiveRecord
def teardown def teardown
super super
IdentityMap.enabled = @enabled IdentityMap.enabled = @enabled
IdentityMap.clear
end end
def test_delegates def test_delegates
@ -55,6 +56,16 @@ module ActiveRecord
assert !IdentityMap.enabled?, 'identity map should be disabled' assert !IdentityMap.enabled?, 'identity map should be disabled'
end 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 end
end end