@@ -188,6 +188,34 @@ def test_app_update_create_new_framework_defaults
188
188
assert_file defaults_path
189
189
end
190
190
191
+ def test_app_update_supports_skip
192
+ run_generator
193
+ FileUtils . cd ( destination_root ) do
194
+ config = "config/application.rb"
195
+ File . open ( config , "a" ) do |file |
196
+ file . puts "# some configuration"
197
+ end
198
+ assert_no_changes -> { File . readlines ( config ) } do
199
+ run_app_update ( flags : "--skip" )
200
+ end
201
+ end
202
+ end
203
+
204
+ def test_app_update_supports_pretend
205
+ run_generator
206
+ FileUtils . cd ( destination_root ) do
207
+ config = "config/application.rb"
208
+ File . open ( config , "a" ) do |file |
209
+ file . puts "# some configuration"
210
+ end
211
+ assert_no_changes -> { File . readlines ( config ) } do
212
+ run_app_update ( flags : "--pretend --force" )
213
+ end
214
+ defaults_path = "config/initializers/new_framework_defaults_#{ Rails ::VERSION ::MAJOR } _#{ Rails ::VERSION ::MINOR } .rb"
215
+ assert_no_file defaults_path
216
+ end
217
+ end
218
+
191
219
def test_app_update_does_not_create_rack_cors
192
220
run_generator
193
221
run_app_update
@@ -1500,13 +1528,13 @@ def run_generator_and_bundler(args)
1500
1528
end
1501
1529
end
1502
1530
1503
- def run_app_update ( app_root = destination_root )
1531
+ def run_app_update ( app_root = destination_root , flags : "--force" )
1504
1532
Dir . chdir ( app_root ) do
1505
1533
gemfile_contents = File . read ( "Gemfile" )
1506
1534
gemfile_contents . sub! ( /^(gem "rails").*/ , "\\ 1, path: #{ File . expand_path ( "../../.." , __dir__ ) . inspect } " )
1507
1535
File . write ( "Gemfile" , gemfile_contents )
1508
1536
1509
- quietly { system ( { "BUNDLE_GEMFILE" => "Gemfile" } , "yes | bin/rails app:update" , exception : true ) }
1537
+ quietly { system ( { "BUNDLE_GEMFILE" => "Gemfile" } , "bin/rails app:update #{ flags } " , exception : true ) }
1510
1538
end
1511
1539
end
1512
1540
0 commit comments