Skip to content

Commit 6675f6b

Browse files
authored
Merge pull request rails#41255 from euxx/fix-create-migration-generator-with-pretend-option
Fix create migration generator with `--pretend` option
2 parents 766ed57 + 557c2e3 commit 6675f6b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

railties/lib/rails/generators/actions/create_migration.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def identical?
2020
end
2121

2222
def invoke!
23+
return super if pretend?
24+
2325
invoked_file = super
2426
File.exist?(@destination) ? invoked_file : relative_existing_migration
2527
end

railties/test/generators/create_migration_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def test_invoke
5555
def test_invoke_pretended
5656
create_migration(default_destination_path, {}, { pretend: true })
5757

58+
stdout = invoke!
59+
assert_match(/create db\/migrate\/1_create_articles\.rb\n/, stdout)
5860
assert_no_file @migration.destination
5961
end
6062

0 commit comments

Comments
 (0)