From 8dd76a7a6ff1bb7105beabb8f834ca54ab1e5fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 13 Nov 2017 15:23:28 -0500 Subject: Use .tt extension to all the template files Make clear that the files are not to be run for interpreters. Fixes #23847. Fixes #30690. Closes #23878. --- .../controller/templates/functional_test.rb | 23 --------- .../controller/templates/functional_test.rb.tt | 23 +++++++++ .../generator/templates/generator_test.rb | 16 ------- .../generator/templates/generator_test.rb.tt | 16 +++++++ .../integration/templates/integration_test.rb | 9 ---- .../integration/templates/integration_test.rb.tt | 9 ++++ .../generators/test_unit/job/job_generator.rb | 2 +- .../test_unit/job/templates/unit_test.rb.erb | 9 ---- .../test_unit/job/templates/unit_test.rb.tt | 9 ++++ .../test_unit/mailer/templates/functional_test.rb | 21 --------- .../mailer/templates/functional_test.rb.tt | 21 +++++++++ .../test_unit/mailer/templates/preview.rb | 13 ------ .../test_unit/mailer/templates/preview.rb.tt | 13 ++++++ .../test_unit/model/templates/fixtures.yml | 29 ------------ .../test_unit/model/templates/fixtures.yml.tt | 29 ++++++++++++ .../test_unit/model/templates/unit_test.rb | 9 ---- .../test_unit/model/templates/unit_test.rb.tt | 9 ++++ .../scaffold/templates/api_functional_test.rb | 44 ------------------ .../scaffold/templates/api_functional_test.rb.tt | 44 ++++++++++++++++++ .../scaffold/templates/functional_test.rb | 54 ---------------------- .../scaffold/templates/functional_test.rb.tt | 54 ++++++++++++++++++++++ .../test_unit/scaffold/templates/system_test.rb | 49 -------------------- .../test_unit/scaffold/templates/system_test.rb.tt | 49 ++++++++++++++++++++ .../templates/application_system_test_case.rb | 5 -- .../templates/application_system_test_case.rb.tt | 5 ++ .../test_unit/system/templates/system_test.rb | 9 ---- .../test_unit/system/templates/system_test.rb.tt | 9 ++++ 27 files changed, 291 insertions(+), 291 deletions(-) delete mode 100644 railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb create mode 100644 railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb create mode 100644 railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb create mode 100644 railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb create mode 100644 railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb create mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/preview.rb create mode 100644 railties/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/model/templates/fixtures.yml create mode 100644 railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt delete mode 100644 railties/lib/rails/generators/test_unit/model/templates/unit_test.rb create mode 100644 railties/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb create mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb create mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb create mode 100644 railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb create mode 100644 railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt delete mode 100644 railties/lib/rails/generators/test_unit/system/templates/system_test.rb create mode 100644 railties/lib/rails/generators/test_unit/system/templates/system_test.rb.tt (limited to 'railties/lib/rails/generators/test_unit') 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 deleted file mode 100644 index ff41fef9e9..0000000000 --- a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest -<% if mountable_engine? -%> - include Engine.routes.url_helpers - -<% end -%> -<% if actions.empty? -%> - # test "the truth" do - # assert true - # end -<% else -%> -<% actions.each do |action| -%> - test "should get <%= action %>" do - get <%= url_helper_prefix %>_<%= action %>_url - assert_response :success - end - -<% end -%> -<% end -%> -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt new file mode 100644 index 0000000000..ff41fef9e9 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt @@ -0,0 +1,23 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest +<% if mountable_engine? -%> + include Engine.routes.url_helpers + +<% end -%> +<% if actions.empty? -%> + # test "the truth" do + # assert true + # end +<% else -%> +<% actions.each do |action| -%> + test "should get <%= action %>" do + get <%= url_helper_prefix %>_<%= action %>_url + assert_response :success + end + +<% end -%> +<% end -%> +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb deleted file mode 100644 index a7f1fc4fba..0000000000 --- a/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'test_helper' -require '<%= generator_path %>' - -<% module_namespacing do -%> -class <%= class_name %>GeneratorTest < Rails::Generators::TestCase - tests <%= class_name %>Generator - destination Rails.root.join('tmp/generators') - setup :prepare_destination - - # test "generator runs without errors" do - # assert_nothing_raised do - # run_generator ["arguments"] - # end - # end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt new file mode 100644 index 0000000000..a7f1fc4fba --- /dev/null +++ b/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt @@ -0,0 +1,16 @@ +require 'test_helper' +require '<%= generator_path %>' + +<% module_namespacing do -%> +class <%= class_name %>GeneratorTest < Rails::Generators::TestCase + tests <%= class_name %>Generator + destination Rails.root.join('tmp/generators') + setup :prepare_destination + + # test "generator runs without errors" do + # assert_nothing_raised do + # run_generator ["arguments"] + # end + # end +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb b/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb deleted file mode 100644 index 118e0f1271..0000000000 --- a/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>Test < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt b/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt new file mode 100644 index 0000000000..118e0f1271 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt @@ -0,0 +1,9 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>Test < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/job/job_generator.rb b/railties/lib/rails/generators/test_unit/job/job_generator.rb index 9225af4e0c..a99ce914c0 100644 --- a/railties/lib/rails/generators/test_unit/job/job_generator.rb +++ b/railties/lib/rails/generators/test_unit/job/job_generator.rb @@ -8,7 +8,7 @@ module TestUnit # :nodoc: check_class_collision suffix: "JobTest" def create_test_file - template "unit_test.rb.erb", File.join("test/jobs", class_path, "#{file_name}_job_test.rb") + template "unit_test.rb", File.join("test/jobs", class_path, "#{file_name}_job_test.rb") end end end diff --git a/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb b/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb deleted file mode 100644 index f5351d0ec6..0000000000 --- a/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>JobTest < ActiveJob::TestCase - # test "the truth" do - # assert true - # end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt b/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt new file mode 100644 index 0000000000..f5351d0ec6 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt @@ -0,0 +1,9 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>JobTest < ActiveJob::TestCase + # test "the truth" do + # assert true + # end +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb deleted file mode 100644 index a2f2d30de5..0000000000 --- a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>MailerTest < ActionMailer::TestCase -<% actions.each do |action| -%> - test "<%= action %>" do - mail = <%= class_name %>Mailer.<%= action %> - assert_equal <%= action.to_s.humanize.inspect %>, mail.subject - assert_equal ["to@example.org"], mail.to - assert_equal ["from@example.com"], mail.from - assert_match "Hi", mail.body.encoded - end - -<% end -%> -<% if actions.blank? -%> - # test "the truth" do - # assert true - # end -<% end -%> -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt new file mode 100644 index 0000000000..a2f2d30de5 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt @@ -0,0 +1,21 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>MailerTest < ActionMailer::TestCase +<% actions.each do |action| -%> + test "<%= action %>" do + mail = <%= class_name %>Mailer.<%= action %> + assert_equal <%= action.to_s.humanize.inspect %>, mail.subject + assert_equal ["to@example.org"], mail.to + assert_equal ["from@example.com"], mail.from + assert_match "Hi", mail.body.encoded + end + +<% end -%> +<% if actions.blank? -%> + # test "the truth" do + # assert true + # end +<% end -%> +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb b/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb deleted file mode 100644 index b063cbc47b..0000000000 --- a/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb +++ /dev/null @@ -1,13 +0,0 @@ -<% module_namespacing do -%> -# Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>_mailer -class <%= class_name %>MailerPreview < ActionMailer::Preview -<% actions.each do |action| -%> - - # Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>_mailer/<%= action %> - def <%= action %> - <%= class_name %>Mailer.<%= action %> - end -<% end -%> - -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt b/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt new file mode 100644 index 0000000000..b063cbc47b --- /dev/null +++ b/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt @@ -0,0 +1,13 @@ +<% module_namespacing do -%> +# Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>_mailer +class <%= class_name %>MailerPreview < ActionMailer::Preview +<% actions.each do |action| -%> + + # Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>_mailer/<%= action %> + def <%= action %> + <%= class_name %>Mailer.<%= action %> + end +<% end -%> + +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml deleted file mode 100644 index 0681780c97..0000000000 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -<% unless attributes.empty? -%> -<% %w(one two).each do |name| %> -<%= name %>: -<% attributes.each do |attribute| -%> - <%- if attribute.password_digest? -%> - password_digest: <%%= BCrypt::Password.create('secret') %> - <%- elsif attribute.reference? -%> - <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default || name) %> - <%- else -%> - <%= yaml_key_value(attribute.column_name, attribute.default) %> - <%- end -%> - <%- if attribute.polymorphic? -%> - <%= yaml_key_value("#{attribute.name}_type", attribute.human_name) %> - <%- end -%> -<% end -%> -<% end -%> -<% else -%> - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt new file mode 100644 index 0000000000..0681780c97 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt @@ -0,0 +1,29 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +<% unless attributes.empty? -%> +<% %w(one two).each do |name| %> +<%= name %>: +<% attributes.each do |attribute| -%> + <%- if attribute.password_digest? -%> + password_digest: <%%= BCrypt::Password.create('secret') %> + <%- elsif attribute.reference? -%> + <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default || name) %> + <%- else -%> + <%= yaml_key_value(attribute.column_name, attribute.default) %> + <%- end -%> + <%- if attribute.polymorphic? -%> + <%= yaml_key_value("#{attribute.name}_type", attribute.human_name) %> + <%- end -%> +<% end -%> +<% end -%> +<% else -%> + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb b/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb deleted file mode 100644 index c9bc7d5b90..0000000000 --- a/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>Test < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt b/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt new file mode 100644 index 0000000000..c9bc7d5b90 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt @@ -0,0 +1,9 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>Test < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end +<% 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 deleted file mode 100644 index f21861d8e6..0000000000 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest - <%- if mountable_engine? -%> - include Engine.routes.url_helpers - - <%- end -%> - setup do - @<%= singular_table_name %> = <%= fixture_name %>(:one) - end - - test "should get index" do - 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_string} }" %> }, as: :json - end - - assert_response 201 - end - - test "should show <%= singular_table_name %>" do - get <%= show_helper %>, as: :json - assert_response :success - end - - test "should update <%= singular_table_name %>" do - patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json - assert_response 200 - end - - test "should destroy <%= singular_table_name %>" do - assert_difference('<%= class_name %>.count', -1) do - delete <%= show_helper %>, as: :json - end - - assert_response 204 - end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt new file mode 100644 index 0000000000..f21861d8e6 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt @@ -0,0 +1,44 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest + <%- if mountable_engine? -%> + include Engine.routes.url_helpers + + <%- end -%> + setup do + @<%= singular_table_name %> = <%= fixture_name %>(:one) + end + + test "should get index" do + 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_string} }" %> }, as: :json + end + + assert_response 201 + end + + test "should show <%= singular_table_name %>" do + get <%= show_helper %>, as: :json + assert_response :success + end + + test "should update <%= singular_table_name %>" do + patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json + assert_response 200 + end + + test "should destroy <%= singular_table_name %>" do + assert_difference('<%= class_name %>.count', -1) do + delete <%= show_helper %>, as: :json + end + + assert_response 204 + end +end +<% end -%> 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 deleted file mode 100644 index 195d60be20..0000000000 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest - <%- if mountable_engine? -%> - include Engine.routes.url_helpers - - <%- end -%> - setup do - @<%= singular_table_name %> = <%= fixture_name %>(:one) - end - - test "should get index" do - get <%= index_helper %>_url - assert_response :success - end - - test "should get new" do - get <%= new_helper %> - 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_string} }" %> } - end - - assert_redirected_to <%= singular_table_name %>_url(<%= class_name %>.last) - end - - test "should show <%= singular_table_name %>" do - get <%= show_helper %> - assert_response :success - end - - test "should get edit" do - get <%= edit_helper %> - assert_response :success - end - - test "should update <%= singular_table_name %>" do - patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> } - assert_redirected_to <%= singular_table_name %>_url(<%= "@#{singular_table_name}" %>) - end - - test "should destroy <%= singular_table_name %>" do - assert_difference('<%= class_name %>.count', -1) do - delete <%= show_helper %> - end - - assert_redirected_to <%= index_helper %>_url - end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt new file mode 100644 index 0000000000..195d60be20 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt @@ -0,0 +1,54 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest + <%- if mountable_engine? -%> + include Engine.routes.url_helpers + + <%- end -%> + setup do + @<%= singular_table_name %> = <%= fixture_name %>(:one) + end + + test "should get index" do + get <%= index_helper %>_url + assert_response :success + end + + test "should get new" do + get <%= new_helper %> + 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_string} }" %> } + end + + assert_redirected_to <%= singular_table_name %>_url(<%= class_name %>.last) + end + + test "should show <%= singular_table_name %>" do + get <%= show_helper %> + assert_response :success + end + + test "should get edit" do + get <%= edit_helper %> + assert_response :success + end + + test "should update <%= singular_table_name %>" do + patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> } + assert_redirected_to <%= singular_table_name %>_url(<%= "@#{singular_table_name}" %>) + end + + test "should destroy <%= singular_table_name %>" do + assert_difference('<%= class_name %>.count', -1) do + delete <%= show_helper %> + end + + assert_redirected_to <%= index_helper %>_url + end +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb deleted file mode 100644 index f83f5a5c62..0000000000 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require "application_system_test_case" - -<% module_namespacing do -%> -class <%= class_name.pluralize %>Test < ApplicationSystemTestCase - setup do - @<%= singular_table_name %> = <%= fixture_name %>(:one) - end - - test "visiting the index" do - visit <%= plural_table_name %>_url - assert_selector "h1", text: "<%= class_name.pluralize.titleize %>" - end - - test "creating a <%= human_name %>" do - visit <%= plural_table_name %>_url - click_on "New <%= class_name.titleize %>" - - <%- attributes_hash.each do |attr, value| -%> - fill_in "<%= attr.humanize.titleize %>", with: <%= value %> - <%- end -%> - click_on "Create <%= human_name %>" - - assert_text "<%= human_name %> was successfully created" - click_on "Back" - end - - test "updating a <%= human_name %>" do - visit <%= plural_table_name %>_url - click_on "Edit", match: :first - - <%- attributes_hash.each do |attr, value| -%> - fill_in "<%= attr.humanize.titleize %>", with: <%= value %> - <%- end -%> - click_on "Update <%= human_name %>" - - assert_text "<%= human_name %> was successfully updated" - click_on "Back" - end - - test "destroying a <%= human_name %>" do - visit <%= plural_table_name %>_url - page.accept_confirm do - click_on "Destroy", match: :first - end - - assert_text "<%= human_name %> was successfully destroyed" - end -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt b/railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt new file mode 100644 index 0000000000..f83f5a5c62 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt @@ -0,0 +1,49 @@ +require "application_system_test_case" + +<% module_namespacing do -%> +class <%= class_name.pluralize %>Test < ApplicationSystemTestCase + setup do + @<%= singular_table_name %> = <%= fixture_name %>(:one) + end + + test "visiting the index" do + visit <%= plural_table_name %>_url + assert_selector "h1", text: "<%= class_name.pluralize.titleize %>" + end + + test "creating a <%= human_name %>" do + visit <%= plural_table_name %>_url + click_on "New <%= class_name.titleize %>" + + <%- attributes_hash.each do |attr, value| -%> + fill_in "<%= attr.humanize.titleize %>", with: <%= value %> + <%- end -%> + click_on "Create <%= human_name %>" + + assert_text "<%= human_name %> was successfully created" + click_on "Back" + end + + test "updating a <%= human_name %>" do + visit <%= plural_table_name %>_url + click_on "Edit", match: :first + + <%- attributes_hash.each do |attr, value| -%> + fill_in "<%= attr.humanize.titleize %>", with: <%= value %> + <%- end -%> + click_on "Update <%= human_name %>" + + assert_text "<%= human_name %> was successfully updated" + click_on "Back" + end + + test "destroying a <%= human_name %>" do + visit <%= plural_table_name %>_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "<%= human_name %> was successfully destroyed" + end +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb b/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb deleted file mode 100644 index d19212abd5..0000000000 --- a/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "test_helper" - -class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400] -end diff --git a/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt b/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt new file mode 100644 index 0000000000..d19212abd5 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/railties/lib/rails/generators/test_unit/system/templates/system_test.rb b/railties/lib/rails/generators/test_unit/system/templates/system_test.rb deleted file mode 100644 index b5ce2ba5c8..0000000000 --- a/railties/lib/rails/generators/test_unit/system/templates/system_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "application_system_test_case" - -class <%= class_name.pluralize %>Test < ApplicationSystemTestCase - # test "visiting the index" do - # visit <%= plural_table_name %>_url - # - # assert_selector "h1", text: "<%= class_name %>" - # end -end diff --git a/railties/lib/rails/generators/test_unit/system/templates/system_test.rb.tt b/railties/lib/rails/generators/test_unit/system/templates/system_test.rb.tt new file mode 100644 index 0000000000..b5ce2ba5c8 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/system/templates/system_test.rb.tt @@ -0,0 +1,9 @@ +require "application_system_test_case" + +class <%= class_name.pluralize %>Test < ApplicationSystemTestCase + # test "visiting the index" do + # visit <%= plural_table_name %>_url + # + # assert_selector "h1", text: "<%= class_name %>" + # end +end -- cgit v1.2.3