aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-01-20 19:16:23 -0500
committerJon Moss <me@jonathanmoss.me>2016-01-20 19:16:23 -0500
commit77acc004efad07dfd4d4f83be14ef897968a3fd9 (patch)
tree9742420e0f68a49460a81c7ae6761998c1b14b8e /actionpack
parent06397336b2c9b1de9462f1baa8075573fd3709dd (diff)
downloadrails-77acc004efad07dfd4d4f83be14ef897968a3fd9.tar.gz
rails-77acc004efad07dfd4d4f83be14ef897968a3fd9.tar.bz2
rails-77acc004efad07dfd4d4f83be14ef897968a3fd9.zip
Re-add ActionController::ApiRendering
- Fixes bug #23142. - Bug was occurring only with ActionController::API, because `_process_options` wasn't being run for API requests, even though it was being run for normal app requests.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller.rb4
-rw-r--r--actionpack/lib/action_controller/api.rb2
-rw-r--r--actionpack/lib/action_controller/api/api_rendering.rb14
-rw-r--r--actionpack/test/controller/api/renderers_test.rb20
4 files changed, 39 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index 3d3af555c9..40f33a9de0 100644
--- a/actionpack/lib/action_controller.rb
+++ b/actionpack/lib/action_controller.rb
@@ -41,6 +41,10 @@ module ActionController
autoload :UrlFor
end
+ autoload_under "api" do
+ autoload :ApiRendering
+ end
+
autoload :TestCase, 'action_controller/test_case'
autoload :TemplateAssertions, 'action_controller/test_case'
diff --git a/actionpack/lib/action_controller/api.rb b/actionpack/lib/action_controller/api.rb
index 1a46d49a49..ff12705abe 100644
--- a/actionpack/lib/action_controller/api.rb
+++ b/actionpack/lib/action_controller/api.rb
@@ -112,7 +112,7 @@ module ActionController
UrlFor,
Redirecting,
- Rendering,
+ ApiRendering,
Renderers::All,
ConditionalGet,
BasicImplicitRender,
diff --git a/actionpack/lib/action_controller/api/api_rendering.rb b/actionpack/lib/action_controller/api/api_rendering.rb
new file mode 100644
index 0000000000..3a08d28c39
--- /dev/null
+++ b/actionpack/lib/action_controller/api/api_rendering.rb
@@ -0,0 +1,14 @@
+module ActionController
+ module ApiRendering
+ extend ActiveSupport::Concern
+
+ included do
+ include Rendering
+ end
+
+ def render_to_body(options = {})
+ _process_options(options)
+ super
+ end
+ end
+end
diff --git a/actionpack/test/controller/api/renderers_test.rb b/actionpack/test/controller/api/renderers_test.rb
index 9405538833..a1307d6f82 100644
--- a/actionpack/test/controller/api/renderers_test.rb
+++ b/actionpack/test/controller/api/renderers_test.rb
@@ -19,6 +19,14 @@ class RenderersApiController < ActionController::API
def two
render xml: Model.new
end
+
+ def plain
+ render plain: 'Hi from plain', status: 500
+ end
+
+ def text
+ render text: 'Hi from text', status: 500
+ end
end
class RenderersApiTest < ActionController::TestCase
@@ -35,4 +43,16 @@ class RenderersApiTest < ActionController::TestCase
assert_response :success
assert_equal({ a: 'b' }.to_xml, @response.body)
end
+
+ def test_render_plain
+ get :plain
+ assert_response :internal_server_error
+ assert_equal('Hi from plain', @response.body)
+ end
+
+ def test_render_text
+ get :text
+ assert_response :internal_server_error
+ assert_equal('Hi from text', @response.body)
+ end
end