aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/metal
diff options
context:
space:
mode:
authorBenjamin Fleischer <github@benjaminfleischer.com>2015-12-06 16:49:52 -0600
committerBenjamin Fleischer <github@benjaminfleischer.com>2015-12-31 13:07:58 -0600
commit1c361ea356aba4936347c83213b2adf50e2f4af2 (patch)
tree80571af314613aca588398e2a6fee1c3e835ca8b /actionpack/test/controller/metal
parent4ff5f6a15bb8f89c07b396a81b825a4efaaecd29 (diff)
downloadrails-1c361ea356aba4936347c83213b2adf50e2f4af2.tar.gz
rails-1c361ea356aba4936347c83213b2adf50e2f4af2.tar.bz2
rails-1c361ea356aba4936347c83213b2adf50e2f4af2.zip
Test ActionController::Renderers::use_renderers
Diffstat (limited to 'actionpack/test/controller/metal')
-rw-r--r--actionpack/test/controller/metal/renderers_test.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/actionpack/test/controller/metal/renderers_test.rb b/actionpack/test/controller/metal/renderers_test.rb
new file mode 100644
index 0000000000..007866a559
--- /dev/null
+++ b/actionpack/test/controller/metal/renderers_test.rb
@@ -0,0 +1,42 @@
+require 'abstract_unit'
+require 'active_support/core_ext/hash/conversions'
+
+class MetalRenderingJsonController < MetalRenderingController
+ class Model
+ def to_json(options = {})
+ { a: 'b' }.to_json(options)
+ end
+
+ def to_xml(options = {})
+ { a: 'b' }.to_xml(options)
+ end
+ end
+
+ use_renderers :json
+
+ def one
+ render json: Model.new
+ end
+
+ def two
+ render xml: Model.new
+ end
+end
+
+class RenderersMetalTest < ActionController::TestCase
+ tests MetalRenderingJsonController
+
+ def test_render_json
+ get :one
+ assert_response :success
+ assert_equal({ a: 'b' }.to_json, @response.body)
+ assert_equal 'application/json', @response.content_type
+ end
+
+ def test_render_xml
+ get :two
+ assert_response :success
+ assert_equal(" ", @response.body)
+ assert_equal 'text/plain', @response.content_type
+ end
+end