From 28e5085070f95f32a6a909cce6d77fd460c73885 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 29 Aug 2018 09:58:21 +0900 Subject: Generate the same value as a label of view in system test template In the system test template, enter a value based on label. However, since `label` method does not use `titleize` by default. If generate a value including underscore, cannot find a label and the test will fail. ``` $ ./bin/rails g scaffold user name:string phone_number:string $ ./bin/rails t test/system/users_test.rb E Error: UsersTest#test_creating_a_User: Capybara::ElementNotFound: Unable to find field "Phone Number" test/system/users_test.rb:18:in `block in ' ``` This removes unnecessary `titleize` so that the generated file will pass even if the attribute contains an underscore. --- .../rails/generators/test_unit/scaffold/templates/system_test.rb.tt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib/rails/generators/test_unit/scaffold') 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 f83f5a5c62..15bd7956b6 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 @@ -16,7 +16,7 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase click_on "New <%= class_name.titleize %>" <%- attributes_hash.each do |attr, value| -%> - fill_in "<%= attr.humanize.titleize %>", with: <%= value %> + fill_in "<%= attr.humanize %>", with: <%= value %> <%- end -%> click_on "Create <%= human_name %>" @@ -29,7 +29,7 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase click_on "Edit", match: :first <%- attributes_hash.each do |attr, value| -%> - fill_in "<%= attr.humanize.titleize %>", with: <%= value %> + fill_in "<%= attr.humanize %>", with: <%= value %> <%- end -%> click_on "Update <%= human_name %>" -- cgit v1.2.3