aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb
diff options
context:
space:
mode:
authorAbdelkader Boudih <terminale@gmail.com>2015-10-27 00:41:27 +0000
committereileencodes <eileencodes@gmail.com>2015-12-15 15:19:16 -0500
commit98a039dcd987fd3a8c2c0cbd527c71ac3ffaaf06 (patch)
tree9a9c694ad27af05f600a74d58d8727ac795a2b85 /railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb
parentf8edd2043e864aff0bde9289da550709532268a6 (diff)
downloadrails-98a039dcd987fd3a8c2c0cbd527c71ac3ffaaf06.tar.gz
rails-98a039dcd987fd3a8c2c0cbd527c71ac3ffaaf06.tar.bz2
rails-98a039dcd987fd3a8c2c0cbd527c71ac3ffaaf06.zip
Update test generators to use ActionDispatch::IntegrationTest
In Rails 5.1 `ActionController::TestCase` will be moved out of Rails into it's own gem. Please use `ActionDispatch::IntegrationTest` going forward. This changes the generators to use `ActionDispatch::IntegrationTest` and the required URL setup (rather than symbols) for each of the controller actions. Updated fix to #22076.
Diffstat (limited to 'railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb')
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb19
1 files changed, 10 insertions, 9 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 f302cd6c3d..de5814eae9 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
@@ -1,40 +1,41 @@
require 'test_helper'
<% module_namespacing do -%>
-class <%= controller_class_name %>ControllerTest < ActionController::TestCase
+class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest
+ <% if mountable_engine? -%>
+ include Engine.routes.url_helpers
+
+ <% end -%>
setup do
@<%= singular_table_name %> = <%= fixture_name %>(:one)
-<% if mountable_engine? -%>
- @routes = Engine.routes
-<% end -%>
end
test "should get index" do
- get :index
+ get <%= index_helper %>_url
assert_response :success
end
test "should create <%= singular_table_name %>" do
assert_difference('<%= class_name %>.count') do
- post :create, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
+ post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
end
assert_response 201
end
test "should show <%= singular_table_name %>" do
- get :show, params: { id: <%= "@#{singular_table_name}" %> }
+ get <%= show_helper %>
assert_response :success
end
test "should update <%= singular_table_name %>" do
- patch :update, params: { id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
+ patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
assert_response 200
end
test "should destroy <%= singular_table_name %>" do
assert_difference('<%= class_name %>.count', -1) do
- delete :destroy, params: { id: <%= "@#{singular_table_name}" %> }
+ delete <%= show_helper %>
end
assert_response 204