aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-05-03 09:52:41 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-05-03 09:59:22 -0700
commitd0719c59384c387aebfdc4a78f6e985bcf5bb270 (patch)
tree84430a5ee109fbb3bdbd7a2ec2f7753cb786d116 /activerecord/test
parent3f897c1a4cef0cb9b53234e10d10d4b8744d61b0 (diff)
downloadrails-d0719c59384c387aebfdc4a78f6e985bcf5bb270.tar.gz
rails-d0719c59384c387aebfdc4a78f6e985bcf5bb270.tar.bz2
rails-d0719c59384c387aebfdc4a78f6e985bcf5bb270.zip
proxying the body in the IM middleware so that IM is available for streaming ERb
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/identity_map/middleware_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/test/cases/identity_map/middleware_test.rb b/activerecord/test/cases/identity_map/middleware_test.rb
index 1004e958e5..130f370da6 100644
--- a/activerecord/test/cases/identity_map/middleware_test.rb
+++ b/activerecord/test/cases/identity_map/middleware_test.rb
@@ -29,6 +29,32 @@ module ActiveRecord
}
mw.call({})
end
+
+ class Enum < Struct.new(:iter)
+ def each(&b)
+ iter.call(&b)
+ end
+ end
+
+ def test_im_enabled_during_body_each
+ mw = Middleware.new lambda { |env|
+ [200, {}, Enum.new(lambda { |&b|
+ assert IdentityMap.enabled?, 'identity map should be enabled'
+ b.call "hello"
+ })]
+ }
+ body = mw.call({}).last
+ body.each { |x| assert_equal 'hello', x }
+ end
+
+ def test_im_disabled_after_body_close
+ mw = Middleware.new lambda { |env| [200, {}, []] }
+ body = mw.call({}).last
+ assert IdentityMap.enabled?, 'identity map should be enabled'
+ body.close
+ assert !IdentityMap.enabled?, 'identity map should be disabled'
+ end
+
end
end
end