aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJeremy W. Rowe <jeremy.w.rowe@gmail.com>2012-11-23 14:30:15 -0600
committerJeremy W. Rowe <jeremy.w.rowe@gmail.com>2013-01-16 15:12:31 -0600
commitc45980fe6e8200837b70482a177bbca87b654fdf (patch)
tree7094050710368e6a5a20a2d13ac59e92f93851a2 /railties
parent555cb0afb5a8a8e98fc982edb9e09dfaafd46380 (diff)
downloadrails-c45980fe6e8200837b70482a177bbca87b654fdf.tar.gz
rails-c45980fe6e8200837b70482a177bbca87b654fdf.tar.bz2
rails-c45980fe6e8200837b70482a177bbca87b654fdf.zip
Fixes improper database name when a '.' is included while creating a new rails
application. EG: `rails new something.awesome.com` Conflicts: railties/CHANGELOG.md
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md5
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb2
-rw-r--r--railties/test/generators/app_generator_test.rb5
3 files changed, 11 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 4f18f4cdd2..ce6c72c135 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Fixes database.yml when creating a new rails application with '.'
+ Fix #8304
+
+ *Jeremy W. Rowe*
+
* Allow a `:dirs` key in the `SourceAnnotationExtractor.enumerate` options
to explicitly set the directories to be traversed so it's easier to define
custom rake tasks.
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index e22be40381..b2d1be9b51 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -236,7 +236,7 @@ module Rails
end
def app_name
- @app_name ||= defined_app_const_base? ? defined_app_name : File.basename(destination_root)
+ @app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr(".", "_")
end
def defined_app_name
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index ee93dc49cd..b2deeb011d 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -164,6 +164,11 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_config_database_app_name_with_period
+ run_generator [File.join(destination_root, "common.usage.com"), "-d", "postgresql"]
+ assert_file "common.usage.com/config/database.yml", /common_usage_com/
+ end
+
def test_config_postgresql_database
run_generator([destination_root, "-d", "postgresql"])
assert_file "config/database.yml", /postgresql/