diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-12-10 22:16:34 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-12-11 11:41:16 +0100 |
commit | 307443972c5f6de959a5401eec76ca327484b10c (patch) | |
tree | 2bf228641f7568a01a5dc4d486355495535d277e | |
parent | 7891de893951c780a1732747d430c33e998dd573 (diff) | |
download | rails-307443972c5f6de959a5401eec76ca327484b10c.tar.gz rails-307443972c5f6de959a5401eec76ca327484b10c.tar.bz2 rails-307443972c5f6de959a5401eec76ca327484b10c.zip |
Skip creating migration if --skip option is passed to model generator [#6144 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
-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 |