aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2017-01-17 15:56:07 +0000
committerGitHub <noreply@github.com>2017-01-17 15:56:07 +0000
commit4965fc124914c0bede4878709097bc1128cc0dea (patch)
treebf29f9ae755c84fbc35affad3325013f9da8d875 /railties/test
parentf7d8752203f791ff4ffc1ef05e05bdf780386378 (diff)
parentc942361a601b9486967ab45bdc3d2d0ce926977f (diff)
downloadrails-4965fc124914c0bede4878709097bc1128cc0dea.tar.gz
rails-4965fc124914c0bede4878709097bc1128cc0dea.tar.bz2
rails-4965fc124914c0bede4878709097bc1128cc0dea.zip
Merge pull request #27674 from kjg/migration_generator_honor_path_config
Generate migrations at path set by `config.paths["db/migrate"]`
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/migration_generator_test.rb10
-rw-r--r--railties/test/generators/model_generator_test.rb10
2 files changed, 20 insertions, 0 deletions
diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb
index 6e1d1b70a9..5ad4372833 100644
--- a/railties/test/generators/migration_generator_test.rb
+++ b/railties/test/generators/migration_generator_test.rb
@@ -309,6 +309,16 @@ class MigrationGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_add_migration_to_configured_path
+ old_paths = Rails.application.config.paths["db/migrate"]
+ Rails.application.config.paths.add "db/migrate", with: "db2/migrate"
+
+ migration = "migration_in_custom_path"
+ run_generator [migration]
+ Rails.application.config.paths["db/migrate"] = old_paths
+ assert_migration "db2/migrate/#{migration}.rb", /.*/
+ end
+
private
def with_singular_table_name
diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb
index 2b9f3ed7f2..0c445729f5 100644
--- a/railties/test/generators/model_generator_test.rb
+++ b/railties/test/generators/model_generator_test.rb
@@ -220,6 +220,16 @@ class ModelGeneratorTest < Rails::Generators::TestCase
ActiveRecord::Base.timestamped_migrations = true
end
+ def test_migration_with_configured_path
+ old_paths = Rails.application.config.paths["db/migrate"]
+ Rails.application.config.paths.add "db/migrate", with: "db2/migrate"
+
+ run_generator
+
+ Rails.application.config.paths["db/migrate"] = old_paths
+ assert_migration "db2/migrate/create_accounts.rb", /class CreateAccounts < ActiveRecord::Migration\[[0-9.]+\]/
+ end
+
def test_model_with_references_attribute_generates_belongs_to_associations
run_generator ["product", "name:string", "supplier:references"]
assert_file "app/models/product.rb", /belongs_to :supplier/