aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-14 10:20:28 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-14 10:39:33 -0700
commit7fa6600b52b7477a958473d504415b7610d39b34 (patch)
tree06dc9681cf0973254d1dd75c0ebdd52a28602e6e /actionpack
parentad311f215da43c6ddac5697ff37e1b93dbcbedcb (diff)
downloadrails-7fa6600b52b7477a958473d504415b7610d39b34.tar.gz
rails-7fa6600b52b7477a958473d504415b7610d39b34.tar.bz2
rails-7fa6600b52b7477a958473d504415b7610d39b34.zip
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
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/journey/router.rb2
-rw-r--r--actionpack/test/dispatch/routing_test.rb3
-rw-r--r--actionpack/test/journey/router_test.rb9
3 files changed, 7 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb
index 543ffc144e..f649588520 100644
--- a/actionpack/lib/action_dispatch/journey/router.rb
+++ b/actionpack/lib/action_dispatch/journey/router.rb
@@ -101,7 +101,7 @@ module ActionDispatch
}
routes =
- if req.request_method == "HEAD"
+ if req.head?
match_head_routes(routes, req)
else
match_routes(routes, req)
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 280b258da6..6e8d7ca7a9 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -3618,7 +3618,7 @@ private
end
class TestAltApp < ActionDispatch::IntegrationTest
- class AltRequest
+ class AltRequest < ActionDispatch::Request
attr_accessor :path_parameters, :path_info, :script_name
attr_reader :env
@@ -3627,6 +3627,7 @@ class TestAltApp < ActionDispatch::IntegrationTest
@env = env
@path_info = "/"
@script_name = ""
+ super
end
def request_method
diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb
index 5c6d9645fb..427d63d75d 100644
--- a/actionpack/test/journey/router_test.rb
+++ b/actionpack/test/journey/router_test.rb
@@ -13,7 +13,10 @@ module ActionDispatch
@formatter = Formatter.new(@routes)
end
- class FakeRequestFeeler < Struct.new(:env, :called)
+ class FakeRequestFeeler < ActionDispatch::Request
+ attr_writer :env
+ attr_accessor :called
+
def new env
self.env = env
self
@@ -23,10 +26,6 @@ module ActionDispatch
self.called = true
'world'
end
-
- def path_info; env['PATH_INFO']; end
- def request_method; env['REQUEST_METHOD']; end
- def ip; env['REMOTE_ADDR']; end
end
def test_dashes