From 9fee1f36dccb7771aaa972ed5fea1504fe1eac1f Mon Sep 17 00:00:00 2001 From: Michael Duchemin Date: Wed, 9 Dec 2020 19:37:45 -0500 Subject: [PATCH] Fix system test scaffold generator for vowels Fix issue where running "rails g scaffold Author" will create system test names like "creating a Author" and "updating a Author" so that there are not grammatical errors. Now running "rails g scaffold Author" will generate "should create Author", "should update Author", and "should destroy Author" which works around the article vowel-sound agreement issues. Fixes #40744 --- guides/source/testing.md | 2 +- railties/CHANGELOG.md | 8 ++++++++ .../test_unit/scaffold/templates/system_test.rb.tt | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/guides/source/testing.md b/guides/source/testing.md index c1e99dad53..311dabe680 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -864,7 +864,7 @@ You can also run `bin/rails test:all` to run all tests, including system tests. Now let's test the flow for creating a new article in our blog. ```ruby -test "creating an article" do +test "should create Article" do visit articles_path click_on "New Article" diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 3e8bbccbfa..c0ce3ea83a 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,11 @@ +* Modified scaffold generator template so that running + `rails g scaffold Author` no longer generates tests called "creating + a Author", "updating a Author", and "destroying a Author" + + Fixes #40744. + + *Michael Duchemin* + * Add benchmark method that can be called from anywhere. This method is used as a quick way to measure & log the speed of some code. 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 index 4f5bbf1108..23838a432e 100644 --- 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 @@ -11,7 +11,7 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase assert_selector "h1", text: "<%= class_name.pluralize.titleize %>" end - test "creating a <%= human_name %>" do + test "should create <%= human_name %>" do visit <%= plural_table_name %>_url click_on "New <%= class_name.titleize %>" @@ -28,7 +28,7 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase click_on "Back" end - test "updating a <%= human_name %>" do + test "should update <%= human_name %>" do visit <%= plural_table_name %>_url click_on "Edit", match: :first @@ -45,7 +45,7 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase click_on "Back" end - test "destroying a <%= human_name %>" do + test "should destroy <%= human_name %>" do visit <%= plural_table_name %>_url page.accept_confirm do click_on "Destroy", match: :first