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

Fix inconsistencies by being polite to the wrapped body. Needed for Rack::Sendfile to function properly. See issue #1761.

This commit is contained in:
Steve Hodgkiss 2011-06-18 22:30:01 +01:00
parent 2fbb7504e2
commit 50444204cc
4 changed files with 34 additions and 0 deletions

View file

@ -426,6 +426,14 @@ module ActiveRecord
@testing = testing
end
def method_missing(method_sym, *arguments, &block)
@body.send(method_sym, *arguments, &block)
end
def respond_to?(method_sym, include_private = false)
super || @body.respond_to?(method_sym)
end
def each(&block)
body.each(&block)
end

View file

@ -33,6 +33,14 @@ module ActiveRecord
@target = target
end
def method_missing(method_sym, *arguments, &block)
@target.send(method_sym, *arguments, &block)
end
def respond_to?(method_sym, include_private = false)
super || @target.respond_to?(method_sym)
end
def each(&block)
@target.each(&block)
end

View file

@ -77,6 +77,13 @@ module ActiveRecord
@management.call(@env)
assert ActiveRecord::Base.connection_handler.active_connections?
end
test "proxy is polite to it's body and responds to it" do
body = Class.new(String) { def to_path; "/path"; end }.new
proxy = ConnectionManagement::Proxy.new(body)
assert proxy.respond_to?(:to_path)
assert_equal proxy.to_path, "/path"
end
end
end
end

View file

@ -203,3 +203,14 @@ class QueryCacheExpiryTest < ActiveRecord::TestCase
end
end
end
class QueryCacheBodyProxyTest < ActiveRecord::TestCase
test "is polite to it's body and responds to it" do
body = Class.new(String) { def to_path; "/path"; end }.new
proxy = ActiveRecord::QueryCache::BodyProxy.new(nil, body)
assert proxy.respond_to?(:to_path)
assert_equal proxy.to_path, "/path"
end
end