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

use predicate methods instead of hard coding verb strings

also change the feeler to subclass AD::Request so that it has all the
methods that Request has
This commit is contained in:
Aaron Patterson 2015-08-14 10:20:28 -07:00
parent ad311f215d
commit 7fa6600b52
3 changed files with 7 additions and 7 deletions

View file

@ -101,7 +101,7 @@ module ActionDispatch
} }
routes = routes =
if req.request_method == "HEAD" if req.head?
match_head_routes(routes, req) match_head_routes(routes, req)
else else
match_routes(routes, req) match_routes(routes, req)

View file

@ -3618,7 +3618,7 @@ private
end end
class TestAltApp < ActionDispatch::IntegrationTest class TestAltApp < ActionDispatch::IntegrationTest
class AltRequest class AltRequest < ActionDispatch::Request
attr_accessor :path_parameters, :path_info, :script_name attr_accessor :path_parameters, :path_info, :script_name
attr_reader :env attr_reader :env
@ -3627,6 +3627,7 @@ class TestAltApp < ActionDispatch::IntegrationTest
@env = env @env = env
@path_info = "/" @path_info = "/"
@script_name = "" @script_name = ""
super
end end
def request_method def request_method

View file

@ -13,7 +13,10 @@ module ActionDispatch
@formatter = Formatter.new(@routes) @formatter = Formatter.new(@routes)
end end
class FakeRequestFeeler < Struct.new(:env, :called) class FakeRequestFeeler < ActionDispatch::Request
attr_writer :env
attr_accessor :called
def new env def new env
self.env = env self.env = env
self self
@ -23,10 +26,6 @@ module ActionDispatch
self.called = true self.called = true
'world' 'world'
end end
def path_info; env['PATH_INFO']; end
def request_method; env['REQUEST_METHOD']; end
def ip; env['REMOTE_ADDR']; end
end end
def test_dashes def test_dashes