Permalink
Browse files

remove NullRequest and just always pass a request class

  • Loading branch information...
1 parent a6e9454 commit 890e0a97fb1179fb0acadf3d7146bb786b0c9e0d @tenderlove tenderlove committed May 23, 2014
Showing with 8 additions and 29 deletions.
  1. +1 −26 actionpack/lib/action_dispatch/journey/router.rb
  2. +7 −3 actionpack/test/journey/router_test.rb
@@ -20,37 +20,12 @@ class RoutingError < ::StandardError # :nodoc:
# :nodoc:
VERSION = '2.0.0'
- class NullReq # :nodoc:
- attr_reader :env
- attr_accessor :path_parameters
- def initialize(env)
- @env = env
- @path_parameters = {}
- end
-
- def request_method
- env['REQUEST_METHOD']
- end
-
- def path_info
- env['PATH_INFO']
- end
-
- def ip
- env['REMOTE_ADDR']
- end
-
- def [](k)
- env[k]
- end
- end
-
attr_reader :request_class, :formatter
attr_accessor :routes
def initialize(routes, options)
@options = options
- @request_class = options[:request_class] || NullReq
+ @request_class = options[:request_class]
@routes = routes
end
@@ -41,7 +41,7 @@ def ip; env['REMOTE_ADDR']; end
end
def test_dashes
- router = Router.new(routes, {})
+ router = Router.new(routes, { :request_class => ActionDispatch::Request })
exp = Router::Strexp.new '/foo-bar-baz', {}, ['/.?']
path = Path::Pattern.new exp
@@ -57,7 +57,7 @@ def test_dashes
end
def test_unicode
- router = Router.new(routes, {})
+ router = Router.new(routes, { :request_class => ActionDispatch::Request })
#match the escaped version of /ほげ
exp = Router::Strexp.new '/%E3%81%BB%E3%81%92', {}, ['/.?']
@@ -113,10 +113,14 @@ def test_request_class_and_requirements_fail
assert_equal env.env, klass.env
end
- class CustomPathRequest < Router::NullReq
+ class CustomPathRequest < ActionDispatch::Request
def path_info
env['custom.path_info']
end
+
+ def path_info=(x)
+ env['custom.path_info'] = x
+ end
end
def test_request_class_overrides_path_info

0 comments on commit 890e0a9

Please sign in to comment.