aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-06-07 21:20:05 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2016-06-07 21:20:05 +0200
commit5eea500ecf5858048ec69dbecb70d3f90f2a1024 (patch)
treea4b69a6e87f888dc0a47b71175756f83e3a61b63 /railties/lib/rails/generators
parentf6464ebdbd313d7dac4fd458cf8bb351b790b5db (diff)
parentd68562e3c7ec8061c766ad8d5e189b5f460903c0 (diff)
downloadrails-5eea500ecf5858048ec69dbecb70d3f90f2a1024.tar.gz
rails-5eea500ecf5858048ec69dbecb70d3f90f2a1024.tar.bz2
rails-5eea500ecf5858048ec69dbecb70d3f90f2a1024.zip
Merge pull request #25317 from prathamesh-sonpatki/fix-api-controller-tests
Fix API controller tests by assigning them the encoding type
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb
index 0d18478043..c469c188e6 100644
--- a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb
+++ b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb
@@ -11,31 +11,31 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
end
test "should get index" do
- get <%= index_helper %>_url
+ get <%= index_helper %>_url, as: :json
assert_response :success
end
test "should create <%= singular_table_name %>" do
assert_difference('<%= class_name %>.count') do
- post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
+ post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }, as: :json
end
assert_response 201
end
test "should show <%= singular_table_name %>" do
- get <%= show_helper %>
+ get <%= show_helper %>, as: :json
assert_response :success
end
test "should update <%= singular_table_name %>" do
- patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
+ patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }, as: :json
assert_response 200
end
test "should destroy <%= singular_table_name %>" do
assert_difference('<%= class_name %>.count', -1) do
- delete <%= show_helper %>
+ delete <%= show_helper %>, as: :json
end
assert_response 204