Skip to content

Commit 876977d

Browse files
authored
Merge pull request rails#46111 from skipkayhil/generate-consistent-app-name
Make app_name consistent between new and update
2 parents 4e7f876 + d3ff40e commit 876977d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

railties/lib/rails/generators/app_name.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module AppName # :nodoc:
77

88
private
99
def app_name
10-
@app_name ||= original_app_name.tr("\\", "").tr("-. ", "_")
10+
@app_name ||= original_app_name.parameterize(preserve_case: true).underscore
1111
end
1212

1313
def original_app_name

railties/test/generators/app_generator_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,12 @@ def test_application_names_are_not_singularized
470470
assert_file "hats/config/environment.rb", /Rails\.application\.initialize!/
471471
end
472472

473+
def test_application_name_is_normalized_in_config
474+
run_generator [File.join(destination_root, "MyWebSite"), "-d", "postgresql"]
475+
assert_file "MyWebSite/app/views/layouts/application.html.erb", /<title>MyWebSite<\/title>/
476+
assert_file "MyWebSite/config/database.yml", /my_web_site_production/
477+
end
478+
473479
def test_gemfile_has_no_whitespace_errors
474480
run_generator
475481
absolute = File.expand_path("Gemfile", destination_root)

0 commit comments

Comments
 (0)