diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-07 20:59:26 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-07 20:59:26 +0100 |
commit | 19e7c524d2831726a51a973b0dc211725496e9d8 (patch) | |
tree | be58b9cb2762c2707c27f10f1a5d880ec0d70e86 | |
parent | 423e2acbb7110961a2774ccd191261c031b83d7a (diff) | |
download | rails-19e7c524d2831726a51a973b0dc211725496e9d8.tar.gz rails-19e7c524d2831726a51a973b0dc211725496e9d8.tar.bz2 rails-19e7c524d2831726a51a973b0dc211725496e9d8.zip |
Ensure config/application.rb also uses app_const instead of app_name.classify.
3 files changed, 8 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index fc6a3cdee8..2f85a0504e 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -193,8 +193,12 @@ module Rails::Generators @app_name ||= File.basename(destination_root) end + def app_const_base + @app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').classify + end + def app_const - @app_const ||= "#{app_name.gsub(/\W/, '_').squeeze('_').classify}::Application" + @app_const ||= "#{app_const_base}::Application" end def valid_app_const? diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index dce5b55d86..334820826f 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -1,6 +1,6 @@ require File.expand_path('../boot', __FILE__) -module <%= app_name.classify %> +module <%= app_const_base %> class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 27537f39b2..85081609de 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -61,7 +61,8 @@ class AppGeneratorTest < GeneratorsTestCase def test_invalid_application_name_is_fixed silence(:stdout){ Rails::Generators::AppGenerator.start [File.join(destination_root, "things-43")] } - assert_file "things-43/config/environment.rb", /Things43::Application/ + assert_file "things-43/config/environment.rb", /Things43::Application\.initialize!/ + assert_file "things-43/config/application.rb", /^module Things43$/ end def test_config_database_is_added_by_default |