diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/migration.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/model_generator_test.rb | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index 8d98909055..0c5c4f6e09 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -52,7 +52,7 @@ module Rails destination = self.class.migration_exists?(migration_dir, @migration_file_name) - if behavior == :invoke + if !(destination && options[:skip]) && behavior == :invoke if destination && options.force? remove_file(destination) elsif destination diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index 8a0f560bc8..552b7eb30a 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -147,10 +147,22 @@ class ModelGeneratorTest < Rails::Generators::TestCase end end - def test_migration_already_exists_error_message + def test_migration_is_skipped_with_skip_option run_generator - error = capture(:stderr){ run_generator ["Account"], :behavior => :skip } - assert_match /Another migration is already named create_accounts/, error + output = run_generator ["Account", "--skip"] + assert_match %r{skip\s+db/migrate/\d+_create_accounts.rb}, output + end + + def test_migration_is_ignored_as_identical_with_skip_option + run_generator ["Account"] + output = run_generator ["Account", "--skip"] + assert_match %r{identical\s+db/migrate/\d+_create_accounts.rb}, output + end + + def test_migration_is_skipped_on_skip_behavior + run_generator + output = run_generator ["Account"], :behavior => :skip + assert_match %r{skip\s+db/migrate/\d+_create_accounts.rb}, output end def test_migration_error_is_not_shown_on_revoke |