mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Trash string coercion rack hacks
This commit is contained in:
parent
76b5f18feb
commit
3f28e0bda6
6 changed files with 0 additions and 73 deletions
|
@ -47,7 +47,6 @@ module ActionDispatch
|
||||||
autoload :Rescue
|
autoload :Rescue
|
||||||
autoload :ShowExceptions
|
autoload :ShowExceptions
|
||||||
autoload :Static
|
autoload :Static
|
||||||
autoload :StringCoercion
|
|
||||||
end
|
end
|
||||||
|
|
||||||
autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
|
autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
module ActionDispatch
|
|
||||||
class StringCoercion
|
|
||||||
class UglyBody < ActiveSupport::BasicObject
|
|
||||||
def initialize(body)
|
|
||||||
@body = body
|
|
||||||
end
|
|
||||||
|
|
||||||
def each
|
|
||||||
@body.each do |part|
|
|
||||||
yield part.to_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def method_missing(*args, &block)
|
|
||||||
@body.__send__(*args, &block)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def initialize(app)
|
|
||||||
@app = app
|
|
||||||
end
|
|
||||||
|
|
||||||
def call(env)
|
|
||||||
status, headers, body = @app.call(env)
|
|
||||||
[status, headers, UglyBody.new(body)]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -114,7 +114,6 @@ end
|
||||||
class ActionController::IntegrationTest < ActiveSupport::TestCase
|
class ActionController::IntegrationTest < ActiveSupport::TestCase
|
||||||
def self.build_app(routes = nil)
|
def self.build_app(routes = nil)
|
||||||
ActionDispatch::MiddlewareStack.new { |middleware|
|
ActionDispatch::MiddlewareStack.new { |middleware|
|
||||||
middleware.use "ActionDispatch::StringCoercion"
|
|
||||||
middleware.use "ActionDispatch::ShowExceptions"
|
middleware.use "ActionDispatch::ShowExceptions"
|
||||||
middleware.use "ActionDispatch::Callbacks"
|
middleware.use "ActionDispatch::Callbacks"
|
||||||
middleware.use "ActionDispatch::ParamsParser"
|
middleware.use "ActionDispatch::ParamsParser"
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
require 'abstract_unit'
|
|
||||||
|
|
||||||
class StringCoercionTest < ActiveSupport::TestCase
|
|
||||||
test "body responds to each" do
|
|
||||||
original_body = []
|
|
||||||
body = ActionDispatch::StringCoercion::UglyBody.new(original_body)
|
|
||||||
|
|
||||||
assert original_body.respond_to?(:each)
|
|
||||||
assert body.respond_to?(:each)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "body responds to to_path" do
|
|
||||||
original_body = []
|
|
||||||
def original_body.to_path; end
|
|
||||||
body = ActionDispatch::StringCoercion::UglyBody.new(original_body)
|
|
||||||
|
|
||||||
assert original_body.respond_to?(:to_path)
|
|
||||||
assert body.respond_to?(:to_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "body does not responds to to_path" do
|
|
||||||
original_body = []
|
|
||||||
body = ActionDispatch::StringCoercion::UglyBody.new(original_body)
|
|
||||||
|
|
||||||
assert !original_body.respond_to?(:to_path)
|
|
||||||
assert !body.respond_to?(:to_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "calls to_s on body parts" do
|
|
||||||
app = lambda { |env|
|
|
||||||
[200, {'Content-Type' => 'html'}, [1, 2, 3]]
|
|
||||||
}
|
|
||||||
app = ActionDispatch::StringCoercion.new(app)
|
|
||||||
parts = []
|
|
||||||
status, headers, body = app.call({})
|
|
||||||
body.each { |part| parts << part }
|
|
||||||
|
|
||||||
assert_equal %w( 1 2 3 ), parts
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -19,7 +19,6 @@ module Rails
|
||||||
middleware.use('ActionDispatch::ParamsParser')
|
middleware.use('ActionDispatch::ParamsParser')
|
||||||
middleware.use('::Rack::MethodOverride')
|
middleware.use('::Rack::MethodOverride')
|
||||||
middleware.use('::Rack::Head')
|
middleware.use('::Rack::Head')
|
||||||
middleware.use('ActionDispatch::StringCoercion')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ module ApplicationTests
|
||||||
"ActionDispatch::ParamsParser",
|
"ActionDispatch::ParamsParser",
|
||||||
"Rack::MethodOverride",
|
"Rack::MethodOverride",
|
||||||
"Rack::Head",
|
"Rack::Head",
|
||||||
"ActionDispatch::StringCoercion",
|
|
||||||
"ActiveRecord::ConnectionAdapters::ConnectionManagement",
|
"ActiveRecord::ConnectionAdapters::ConnectionManagement",
|
||||||
"ActiveRecord::QueryCache"
|
"ActiveRecord::QueryCache"
|
||||||
], middleware
|
], middleware
|
||||||
|
|
Loading…
Reference in a new issue