diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-06 14:17:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-06 14:17:57 -0700 |
commit | 2090615d39c071c9eb25e715275eb79f3f9b6266 (patch) | |
tree | 34408663c46c6fe2bf92607da30fd9eff10b8521 /actionpack | |
parent | 3dfcae6afa24b641bd838b9044c5ce9aa2a1a6db (diff) | |
download | rails-2090615d39c071c9eb25e715275eb79f3f9b6266.tar.gz rails-2090615d39c071c9eb25e715275eb79f3f9b6266.tar.bz2 rails-2090615d39c071c9eb25e715275eb79f3f9b6266.zip |
refactor Redirecting so we do not need a controller instance
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/redirecting.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/response.rb | 9 |
2 files changed, 7 insertions, 10 deletions
diff --git a/actionpack/lib/action_controller/metal/redirecting.rb b/actionpack/lib/action_controller/metal/redirecting.rb index ca8c0278d0..acaa8227c9 100644 --- a/actionpack/lib/action_controller/metal/redirecting.rb +++ b/actionpack/lib/action_controller/metal/redirecting.rb @@ -72,11 +72,11 @@ module ActionController raise AbstractController::DoubleRenderError if response_body self.status = _extract_redirect_to_status(options, response_status) - self.location = _compute_redirect_to_location(options) + self.location = _compute_redirect_to_location(request, options) self.response_body = "<html><body>You are being <a href=\"#{ERB::Util.unwrapped_html_escape(location)}\">redirected</a>.</body></html>" end - def _compute_redirect_to_location(options) #:nodoc: + def _compute_redirect_to_location(request, options) #:nodoc: case options # The scheme name consist of a letter followed by any combination of # letters, digits, and the plus ("+"), period ("."), or hyphen ("-") @@ -90,11 +90,13 @@ module ActionController when :back request.headers["Referer"] or raise RedirectBackError when Proc - _compute_redirect_to_location options.call + _compute_redirect_to_location request, options.call else url_for(options) end.delete("\0\r\n") end + module_function :_compute_redirect_to_location + public :_compute_redirect_to_location private def _extract_redirect_to_status(options, response_status) diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index 0adc6c84ff..13a72220b3 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -73,13 +73,8 @@ module ActionDispatch if Regexp === fragment fragment else - handle = @controller || Class.new(ActionController::Metal) do - include ActionController::Redirecting - def initialize(request) - @_request = request - end - end.new(@request) - handle._compute_redirect_to_location(fragment) + handle = @controller || ActionController::Redirecting + handle._compute_redirect_to_location(@request, fragment) end end end |