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:
parent
d0719c5938
commit
cb9557c432
2 changed files with 12 additions and 0 deletions
|
@ -112,6 +112,7 @@ module ActiveRecord
|
|||
@target.close if @target.respond_to?(:close)
|
||||
ensure
|
||||
IdentityMap.enabled = @original
|
||||
IdentityMap.clear
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue