aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime
diff options
context:
space:
mode:
authorLukasz Strzalkowski <lukaszstrzalkowski@squareup.com>2014-02-13 15:59:09 +0100
committerLukasz Strzalkowski <lukaszstrzalkowski@squareup.com>2014-02-13 16:22:56 +0100
commitf9b6b865e60ea770cc34e9946f6df1604f20dd27 (patch)
tree552d0ab1ade45463bf5acdfe53a7ac6944806cbe /actionpack/test/controller/mime
parentde5ef153984f4fc3229a3346a8a4a1595303afc8 (diff)
downloadrails-f9b6b865e60ea770cc34e9946f6df1604f20dd27.tar.gz
rails-f9b6b865e60ea770cc34e9946f6df1604f20dd27.tar.bz2
rails-f9b6b865e60ea770cc34e9946f6df1604f20dd27.zip
Variant negotiation
Allow setting `request.variant` as an array - an order in which they will be rendered. For example: request.variant = [:tablet, :phone] respond_to do |format| format.html.none format.html.phone # this gets rendered end
Diffstat (limited to 'actionpack/test/controller/mime')
-rw-r--r--actionpack/test/controller/mime/respond_to_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb
index 84e4936f31..2f05017ec9 100644
--- a/actionpack/test/controller/mime/respond_to_test.rb
+++ b/actionpack/test/controller/mime/respond_to_test.rb
@@ -740,4 +740,25 @@ class RespondToControllerTest < ActionController::TestCase
assert_equal "text/javascript", @response.content_type
assert_equal "tablet", @response.body
end
+
+ def test_variant_negotiation_inline_syntax
+ @request.variant = [:tablet, :phone]
+ get :variant_inline_syntax_without_block
+ assert_equal "text/html", @response.content_type
+ assert_equal "phone", @response.body
+ end
+
+ def test_variant_negotiation_block_syntax
+ @request.variant = [:tablet, :phone]
+ get :variant_plus_none_for_format
+ assert_equal "text/html", @response.content_type
+ assert_equal "phone", @response.body
+ end
+
+ def test_variant_negotiation_without_block
+ @request.variant = [:tablet, :phone]
+ get :variant_inline_syntax_without_block
+ assert_equal "text/html", @response.content_type
+ assert_equal "phone", @response.body
+ end
end