diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-08-03 11:34:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-03 11:34:21 -0400 |
commit | c6dcee4770b06ee3cd88a63cceb3988806ffd383 (patch) | |
tree | f0f6577fd307469f958b83b9e7fe815c414bb5a5 /railties/test/generators | |
parent | f105ab0445b07d11d551678f9fbc3298301da5a1 (diff) | |
parent | 1cc6c74db20de139f6ad3bedc7cd7e28dc83283e (diff) | |
download | rails-c6dcee4770b06ee3cd88a63cceb3988806ffd383.tar.gz rails-c6dcee4770b06ee3cd88a63cceb3988806ffd383.tar.bz2 rails-c6dcee4770b06ee3cd88a63cceb3988806ffd383.zip |
Merge pull request #30011 from guilherme/fix-migration-generator-special-cases
Handling add/remove to/from migration edge cases
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/migration_generator_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb index 6fe6e4ca07..db0808750e 100644 --- a/railties/test/generators/migration_generator_test.rb +++ b/railties/test/generators/migration_generator_test.rb @@ -48,6 +48,17 @@ class MigrationGeneratorTest < Rails::Generators::TestCase end end + def test_add_migration_with_table_having_from_in_title + migration = "add_email_address_to_blacklisted_from_campaign" + run_generator [migration, "email_address:string"] + + assert_migration "db/migrate/#{migration}.rb" do |content| + assert_method :change, content do |change| + assert_match(/add_column :blacklisted_from_campaigns, :email_address, :string/, change) + end + end + end + def test_remove_migration_with_indexed_attribute migration = "remove_title_body_from_posts" run_generator [migration, "title:string:index", "body:text"] @@ -73,6 +84,17 @@ class MigrationGeneratorTest < Rails::Generators::TestCase end end + def test_remove_migration_with_table_having_to_in_title + migration = "remove_email_address_from_sent_to_user" + run_generator [migration, "email_address:string"] + + assert_migration "db/migrate/#{migration}.rb" do |content| + assert_method :change, content do |change| + assert_match(/remove_column :sent_to_users, :email_address, :string/, change) + end + end + end + def test_remove_migration_with_references_options migration = "remove_references_from_books" run_generator [migration, "author:belongs_to", "distributor:references{polymorphic}"] |