Fix create migration generator with `--pretend` option

This commit is contained in:
eux 2021-01-27 21:00:24 +08:00
parent c38db72472
commit 557c2e349f
2 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,8 @@ module Rails
end
def invoke!
return super if pretend?
invoked_file = super
File.exist?(@destination) ? invoked_file : relative_existing_migration
end

View File

@ -55,6 +55,8 @@ class CreateMigrationTest < Rails::Generators::TestCase
def test_invoke_pretended
create_migration(default_destination_path, {}, { pretend: true })
stdout = invoke!
assert_match(/create db\/migrate\/1_create_articles\.rb\n/, stdout)
assert_no_file @migration.destination
end