aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2014-12-31 12:21:55 +0100
committerRobin Dupret <robin.dupret@gmail.com>2014-12-31 16:37:35 +0100
commit7ef7f1cc152a4b180dd455ffa859bf11d1daeda0 (patch)
tree4c48d09fc580310570ae9b1d8cac02353f907a3a /actionpack/lib/action_controller
parent7d1718f49eda0f78216bb232977bf254f7f32ebb (diff)
downloadrails-7ef7f1cc152a4b180dd455ffa859bf11d1daeda0.tar.gz
rails-7ef7f1cc152a4b180dd455ffa859bf11d1daeda0.tar.bz2
rails-7ef7f1cc152a4b180dd455ffa859bf11d1daeda0.zip
Correctly use the response's status code calling head
Commit 20fece1 introduced the `_status_code` method to fix calls to `head :ok`. This method has been added on both ActionController::Metal and ActionDispatch::Response. As for the latter, this method is just equivalent to the `response_code` one so commit aefec3c removed it from the `Reponse` object so call to the `_status_code` method on an ActionController::Base instance would be handled by the `Metal` class (which `Base` inherits from) but the status code is not updated according to the response at this level. The fix is to actually rely on `response_code` for ActionController::Base instances but this method doesn't exist for bare Metal controllers so we need to define it.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/metal.rb5
-rw-r--r--actionpack/lib/action_controller/metal/head.rb2
2 files changed, 2 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index 6dd213b2f7..993f8e150d 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -173,6 +173,7 @@ module ActionController
def status
@_status
end
+ alias :response_code :status # :nodoc:
def status=(status)
@_status = Rack::Utils.status_code(status)
@@ -236,9 +237,5 @@ module ActionController
lambda { |env| new.dispatch(name, klass.new(env)) }
end
end
-
- def _status_code #:nodoc:
- @_status
- end
end
end
diff --git a/actionpack/lib/action_controller/metal/head.rb b/actionpack/lib/action_controller/metal/head.rb
index 57e60222cd..0d93e2f7aa 100644
--- a/actionpack/lib/action_controller/metal/head.rb
+++ b/actionpack/lib/action_controller/metal/head.rb
@@ -31,7 +31,7 @@ module ActionController
self.response_body = ""
- if include_content?(self._status_code)
+ if include_content?(self.response_code)
self.content_type = content_type || (Mime[formats.first] if formats)
self.response.charset = false if self.response
else