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

remove vestigial code

Looks like this was left over from converting Rails to Rack.  I think
it's safe to remove now.
This commit is contained in:
Aaron Patterson 2015-08-07 16:17:22 -07:00
parent 81cfdf2489
commit 1f80f3a373
2 changed files with 0 additions and 82 deletions

View file

@ -1,39 +0,0 @@
module ActionController
class Middleware < Metal
class ActionMiddleware
def initialize(controller, app)
@controller, @app = controller, app
end
def call(env)
request = ActionDispatch::Request.new(env)
@controller.build(@app).dispatch(:index, request)
end
end
class << self
alias build new
def new(app)
ActionMiddleware.new(self, app)
end
end
attr_internal :app
def process(action)
response = super
self.status, self.headers, self.response_body = response if response.is_a?(Array)
response
end
def initialize(app)
super()
@_app = app
end
def index
call(env)
end
end
end

View file

@ -1,43 +0,0 @@
require 'abstract_unit'
module MetalTest
class MetalMiddleware < ActionController::Middleware
def call(env)
if env["PATH_INFO"] =~ /authed/
app.call(env)
else
[401, headers, "Not authed!"]
end
end
end
class Endpoint
def call(env)
[200, {}, "Hello World"]
end
end
class TestMiddleware < ActiveSupport::TestCase
def setup
@app = Rack::Builder.new do
use MetalTest::MetalMiddleware
run MetalTest::Endpoint.new
end.to_app
end
test "it can call the next app by using @app" do
env = Rack::MockRequest.env_for("/authed")
response = @app.call(env)
assert_equal ["Hello World"], response[2]
end
test "it can return a response using the normal AC::Metal techniques" do
env = Rack::MockRequest.env_for("/")
response = @app.call(env)
assert_equal ["Not authed!"], response[2]
assert_equal 401, response[0]
end
end
end