Permalink
Browse files

Skip creating migration if --skip option is passed to model generator [

…#6144 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
drogus authored and vijaydev committed Dec 10, 2010
1 parent e6928e8 commit 0dc39cd8ee24466f204a292ae61643ce3b3b4c32
Showing with 16 additions and 4 deletions.
  1. +1 −1 railties/lib/rails/generators/migration.rb
  2. +15 −3 railties/test/generators/model_generator_test.rb
@@ -52,7 +52,7 @@ def migration_template(source, destination=nil, config={})
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
@@ -147,10 +147,22 @@ def test_migration_timestamps_are_skipped
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

0 comments on commit 0dc39cd

Please sign in to comment.