aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@gmail.com>2015-12-13 16:19:30 -0500
committerEileen M. Uchitelle <eileencodes@gmail.com>2015-12-13 16:19:30 -0500
commit9712a7a12b7f9e4dcef751ceda8a73c3f4beb11f (patch)
treef12e42145656e222d1f735c3ee96903aad1ea181 /railties/lib/rails
parent3e65c3d3886336e9145438cdeacaf4ebec6a48b8 (diff)
parent5541d640cf455ae95544dba411ba71367cbc97ff (diff)
downloadrails-9712a7a12b7f9e4dcef751ceda8a73c3f4beb11f.tar.gz
rails-9712a7a12b7f9e4dcef751ceda8a73c3f4beb11f.tar.bz2
rails-9712a7a12b7f9e4dcef751ceda8a73c3f4beb11f.zip
Merge pull request #22569 from seuros/remove-test-case
Controller generators should be creating IntegrationTest stubs instea…
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb4
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb12
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb17
3 files changed, 17 insertions, 16 deletions
diff --git a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb
index 5a8a3ca5e0..62c7e2f011 100644
--- a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb
+++ b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
<% module_namespacing do -%>
-class <%= class_name %>ControllerTest < ActionController::TestCase
+class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest
<% if mountable_engine? -%>
setup do
@routes = Engine.routes
@@ -15,7 +15,7 @@ class <%= class_name %>ControllerTest < ActionController::TestCase
<% else -%>
<% actions.each do |action| -%>
test "should get <%= action %>" do
- get :<%= action %>
+ get url_for(action: :<%= action %>)
assert_response :success
end
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..412ecb8db1 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,7 +1,7 @@
require 'test_helper'
<% module_namespacing do -%>
-class <%= controller_class_name %>ControllerTest < ActionController::TestCase
+class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest
setup do
@<%= singular_table_name %> = <%= fixture_name %>(:one)
<% if mountable_engine? -%>
@@ -10,31 +10,31 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
end
test "should get index" do
- get :index
+ get url_for( controller: :<%= controller_name %>, action: :index )
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 url_for( controller: :<%= controller_name %>, action: :create, <%= "#{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 url_for( controller: :<%= controller_name %>, action: :show, id: <%= "@#{singular_table_name}" %> )
assert_response :success
end
test "should update <%= singular_table_name %>" do
- patch :update, params: { id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
+ patch url_for( controller: :<%= controller_name %>, action: :update, id: <%= "@#{singular_table_name}" %>, <%= "#{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 url_for( controller: :<%= controller_name %>, action: :destroy, id: <%= "@#{singular_table_name}" %> )
end
assert_response 204
diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
index 50b98b2631..3ac0b611ac 100644
--- a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
+++ b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
@@ -1,50 +1,51 @@
require 'test_helper'
<% module_namespacing do -%>
-class <%= controller_class_name %>ControllerTest < ActionController::TestCase
+class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest
setup do
@<%= singular_table_name %> = <%= fixture_name %>(:one)
<% if mountable_engine? -%>
+
@routes = Engine.routes
<% end -%>
end
test "should get index" do
- get :index
+ get url_for( controller: :<%= controller_name %>, action: :index )
assert_response :success
end
test "should get new" do
- get :new
+ get url_for( controller: :<%= controller_name %>, action: :new )
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 url_for( controller: :<%= controller_name %>, action: :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %> )
end
assert_redirected_to <%= singular_table_name %>_path(<%= class_name %>.last)
end
test "should show <%= singular_table_name %>" do
- get :show, params: { id: <%= "@#{singular_table_name}" %> }
+ get url_for( controller: :<%= controller_name %>, action: :show, id: <%= "@#{singular_table_name}" %> )
assert_response :success
end
test "should get edit" do
- get :edit, params: { id: <%= "@#{singular_table_name}" %> }
+ get url_for( controller: :<%= controller_name %>, action: :edit, id: <%= "@#{singular_table_name}" %> )
assert_response :success
end
test "should update <%= singular_table_name %>" do
- patch :update, params: { id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> }
+ patch url_for( controller: :<%= controller_name %>, action: :update, id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> )
assert_redirected_to <%= singular_table_name %>_path(<%= "@#{singular_table_name}" %>)
end
test "should destroy <%= singular_table_name %>" do
assert_difference('<%= class_name %>.count', -1) do
- delete :destroy, params: { id: <%= "@#{singular_table_name}" %> }
+ delete url_for( controller: :<%= controller_name %>, action: :destroy, id: <%= "@#{singular_table_name}" %> )
end
assert_redirected_to <%= index_helper %>_path