From 52b252614e275da799b6a15cebbfd067c59987d1 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Tue, 22 Oct 2013 13:17:52 +0200 Subject: Make the application name snake cased when it contains spaces The application name is used to fill the `database.yml` and `session_store.rb` files ; previously, if the provided name contained whitespaces, it led to unexpected names in these files. Since Shellwords.escape adds backslashes to escape spaces, the app_name should remove them and replace any space with an underscore (just like periods previously). Also improve the assert_file helper to work with paths containing spaces using String#shellescape. --- railties/lib/rails/generators/rails/app/app_generator.rb | 2 +- railties/lib/rails/generators/testing/assertions.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 92c876c835..db6b11abfa 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -239,7 +239,7 @@ module Rails end def app_name - @app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr(".", "_") + @app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr('\\', '').tr(". ", "_") end def defined_app_name diff --git a/railties/lib/rails/generators/testing/assertions.rb b/railties/lib/rails/generators/testing/assertions.rb index 6267b2f2ee..cc88e830dd 100644 --- a/railties/lib/rails/generators/testing/assertions.rb +++ b/railties/lib/rails/generators/testing/assertions.rb @@ -21,7 +21,7 @@ module Rails # end # end def assert_file(relative, *contents) - absolute = File.expand_path(relative, destination_root) + absolute = File.expand_path(relative, destination_root).shellescape assert File.exists?(absolute), "Expected file #{relative.inspect} to exist, but does not" read = File.read(absolute) if block_given? || !contents.empty? -- cgit v1.2.3