aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJustin Coyne <jcoyne@justincoyne.com>2015-12-30 12:59:23 -0600
committerJustin Coyne <jcoyne@justincoyne.com>2016-02-25 07:14:49 -0600
commit48f140cf7459c963a54637c897448b959dbbfd26 (patch)
tree96ab619b7aa2d8fb9adf591a735ed3673a290e2a /actionpack/test
parent46cb45df485d6f4d67a8e448a142bcab47fc0f2a (diff)
downloadrails-48f140cf7459c963a54637c897448b959dbbfd26.tar.gz
rails-48f140cf7459c963a54637c897448b959dbbfd26.tar.bz2
rails-48f140cf7459c963a54637c897448b959dbbfd26.zip
Render default template if block doesn't render
When a `respond_to` collector doesn't have a response, then a `:no_content` response should be rendered. This brings the default rendering behavior introduced by https://github.com/rails/rails/issues/19036 to controller methods employing `respond_to`
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/mime/respond_to_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb
index d0c7b2e06a..993f4001de 100644
--- a/actionpack/test/controller/mime/respond_to_test.rb
+++ b/actionpack/test/controller/mime/respond_to_test.rb
@@ -74,6 +74,14 @@ class RespondToController < ActionController::Base
end
end
+ def missing_templates
+ respond_to do |type|
+ # This test requires a block that is empty
+ type.json { }
+ type.xml
+ end
+ end
+
def using_defaults_with_type_list
respond_to(:html, :xml)
end
@@ -624,6 +632,13 @@ class RespondToControllerTest < ActionController::TestCase
end
end
+ def test_missing_templates
+ get :missing_templates, format: :json
+ assert_response :no_content
+ get :missing_templates, format: :xml
+ assert_response :no_content
+ end
+
def test_invalid_variant
assert_raises(ActionController::UnknownFormat) do
get :variant_with_implicit_template_rendering, params: { v: :invalid }