aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorRichard Schneeman <richard.schneeman+no-recruiters@gmail.com>2018-07-31 07:08:59 -0400
committerGitHub <noreply@github.com>2018-07-31 07:08:59 -0400
commit5deab3d26c28f52daf52922971cbd7ab1f0569de (patch)
tree95ca04ce73a2d22fe5abee718118ea2c1e375553 /actionpack/test
parent69f6c4d2af43f2e19c73b89755c3c19733207987 (diff)
parent84e8b350a3c3b9dbf4333fb21979688b3eb1f19e (diff)
downloadrails-5deab3d26c28f52daf52922971cbd7ab1f0569de.tar.gz
rails-5deab3d26c28f52daf52922971cbd7ab1f0569de.tar.bz2
rails-5deab3d26c28f52daf52922971cbd7ab1f0569de.zip
Merge pull request #33446 from ptoomey3/nested-respond-to
Raises exception when respond_to called multiple times in incompatible way
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/mime/respond_to_test.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb
index 771eccb29b..1163775d3c 100644
--- a/actionpack/test/controller/mime/respond_to_test.rb
+++ b/actionpack/test/controller/mime/respond_to_test.rb
@@ -102,6 +102,26 @@ class RespondToController < ActionController::Base
end
end
+ def using_conflicting_nested_js_then_html
+ respond_to do |outer_type|
+ outer_type.js do
+ respond_to do |inner_type|
+ inner_type.html { render body: "HTML" }
+ end
+ end
+ end
+ end
+
+ def using_non_conflicting_nested_js_then_js
+ respond_to do |outer_type|
+ outer_type.js do
+ respond_to do |inner_type|
+ inner_type.js { render body: "JS" }
+ end
+ end
+ end
+ end
+
def custom_type_handling
respond_to do |type|
type.html { render body: "HTML" }
@@ -430,6 +450,20 @@ class RespondToControllerTest < ActionController::TestCase
assert_equal "<p>Hello world!</p>\n", @response.body
end
+ def test_using_conflicting_nested_js_then_html
+ @request.accept = "*/*"
+ assert_raises(ActionController::RespondToMismatchError) do
+ get :using_conflicting_nested_js_then_html
+ end
+ end
+
+ def test_using_non_conflicting_nested_js_then_js
+ @request.accept = "*/*"
+ get :using_non_conflicting_nested_js_then_js
+ assert_equal "text/javascript", @response.content_type
+ assert_equal "JS", @response.body
+ end
+
def test_with_atom_content_type
@request.accept = ""
@request.env["CONTENT_TYPE"] = "application/atom+xml"