@@ -50,7 +50,7 @@ def test_implied_options_with_conflicting_option
50
50
assert_match %r/conflicting option/i , error . message
51
51
end
52
52
53
- def test_skeleton_is_created
53
+ def test_codebase_is_created
54
54
run_generator
55
55
56
56
generated_files_and_folders = [ ]
@@ -78,6 +78,25 @@ def test_skeleton_is_created
78
78
assert_equal generated_files_and_folders . sort , default_files , "The expected list of generated files is not alphabetical"
79
79
80
80
default_files . each { |path | assert_file path }
81
+
82
+ assert_file "#{ application_path } /config/application.rb" , /\s +require\s +["']rails\/ all["']/
83
+
84
+ assert_file "#{ application_path } /config/environments/development.rb" do |content |
85
+ assert_match ( /config\. action_mailer\. raise_delivery_errors = false/ , content )
86
+ assert_match ( /config\. active_storage/ , content )
87
+ end
88
+ assert_file "#{ application_path } /config/environments/test.rb" do |content |
89
+ assert_match ( /config\. action_mailer\. delivery_method = :test/ , content )
90
+ assert_match ( /config\. active_storage/ , content )
91
+ end
92
+ assert_file "#{ application_path } /config/environments/production.rb" do |content |
93
+ assert_match ( /# config\. action_mailer\. raise_delivery_errors = false/ , content )
94
+ assert_match ( /^ # config\. require_master_key = true/ , content )
95
+ assert_match ( /config\. active_storage/ , content )
96
+ end
97
+
98
+ assert_load_defaults
99
+ assert_gem_for_active_storage
81
100
end
82
101
83
102
def test_plugin_new_generate_pretend
@@ -223,59 +242,25 @@ def test_default_frameworks_are_required_when_others_are_removed
223
242
assert_file "#{ application_path } /config/application.rb" , /^require\s +["']rails\/ test_unit\/ railtie["']/
224
243
end
225
244
226
- def test_generator_without_skips
227
- run_generator
228
- assert_file "#{ application_path } /config/application.rb" , /\s +require\s +["']rails\/ all["']/
229
- assert_file "#{ application_path } /config/environments/development.rb" do |content |
230
- assert_match ( /config\. action_mailer\. raise_delivery_errors = false/ , content )
231
- end
232
- assert_file "#{ application_path } /config/environments/test.rb" do |content |
233
- assert_match ( /config\. action_mailer\. delivery_method = :test/ , content )
234
- end
235
- assert_file "#{ application_path } /config/environments/production.rb" do |content |
236
- assert_match ( /# config\. action_mailer\. raise_delivery_errors = false/ , content )
237
- assert_match ( /^ # config\. require_master_key = true/ , content )
238
- end
239
- end
240
-
241
245
def test_generator_if_skip_active_record_is_given
242
246
run_generator [ destination_root , "--skip-active-record" ]
243
247
assert_no_directory "#{ application_path } /db/"
244
248
assert_no_file "#{ application_path } /config/database.yml"
245
249
assert_no_file "#{ application_path } /app/models/application_record.rb"
246
- assert_file "#{ application_path } /config/application.rb" , /#\s +require\s +["']active_record\/ railtie["']/
250
+
251
+ assert_file "#{ application_path } /config/application.rb" do |content |
252
+ assert_match ( /#\s +require\s +["']active_record\/ railtie["']/ , content )
253
+ assert_match ( /#\s +require\s +["']active_storage\/ engine["']/ , content )
254
+ assert_match ( /#\s +require\s +["']action_mailbox\/ engine["']/ , content )
255
+ assert_match ( /#\s +require\s +["']action_text\/ engine["']/ , content )
256
+ end
257
+
247
258
assert_file "test/test_helper.rb" do |helper_content |
248
259
assert_no_match ( /fixtures :all/ , helper_content )
249
260
end
250
261
assert_file "#{ application_path } /bin/setup" do |setup_content |
251
262
assert_no_match ( /db:prepare/ , setup_content )
252
263
end
253
- end
254
-
255
- def test_generator_for_active_storage
256
- run_generator ( [ destination_root ] )
257
-
258
- assert_file "#{ application_path } /config/environments/development.rb" do |content |
259
- assert_match ( /config\. active_storage/ , content )
260
- end
261
-
262
- assert_file "#{ application_path } /config/environments/production.rb" do |content |
263
- assert_match ( /config\. active_storage/ , content )
264
- end
265
-
266
- assert_file "#{ application_path } /config/environments/test.rb" do |content |
267
- assert_match ( /config\. active_storage/ , content )
268
- end
269
-
270
- assert_file "#{ application_path } /config/storage.yml"
271
- assert_directory "#{ application_path } /storage"
272
- assert_directory "#{ application_path } /tmp/storage"
273
- end
274
-
275
- def test_generator_if_skip_active_storage_is_given
276
- run_generator [ destination_root , "--skip-active-storage" ]
277
-
278
- assert_file "#{ application_path } /config/application.rb" , /#\s +require\s +["']active_storage\/ engine["']/
279
264
280
265
assert_file "#{ application_path } /config/environments/development.rb" do |content |
281
266
assert_no_match ( /config\. active_storage/ , content )
@@ -290,12 +275,18 @@ def test_generator_if_skip_active_storage_is_given
290
275
end
291
276
292
277
assert_no_file "#{ application_path } /config/storage.yml"
278
+
279
+ assert_gitattributes_does_not_have_schema_file
280
+
281
+ assert_file "Gemfile" do |contents |
282
+ assert_no_match ( /sqlite/ , contents )
283
+ end
293
284
end
294
285
295
- def test_generator_does_not_generate_active_storage_contents_if_skip_active_record_is_given
296
- run_generator [ destination_root , "--skip-active-record " ]
286
+ def test_generator_if_skip_active_storage_is_given
287
+ run_generator [ destination_root , "--skip-active-storage " ]
297
288
298
- assert_file " #{ application_path } /config/application.rb" , /# \s +require \s +["']active_storage \/ engine["']/
289
+ assert_frameworks_are_not_required_when_active_storage_is_skipped
299
290
300
291
assert_file "#{ application_path } /config/environments/development.rb" do |content |
301
292
assert_no_match ( /config\. active_storage/ , content )
@@ -310,6 +301,9 @@ def test_generator_does_not_generate_active_storage_contents_if_skip_active_reco
310
301
end
311
302
312
303
assert_no_file "#{ application_path } /config/storage.yml"
304
+
305
+ assert_gems_when_active_storage_is_skipped
306
+ assert_dockerfile_when_active_storage_is_skipped
313
307
end
314
308
315
309
def test_generator_does_not_create_storage_dir_if_skip_active_storage_is_given_and_not_using_sqlite
@@ -405,6 +399,25 @@ def test_target_rails_prerelease_with_relative_app_path
405
399
end
406
400
407
401
private
402
+ def assert_load_defaults
403
+ end
404
+
405
+ def assert_gem_for_active_storage
406
+ end
407
+
408
+ def assert_frameworks_are_not_required_when_active_storage_is_skipped
409
+ assert_file "#{ application_path } /config/application.rb" , /#\s +require\s +["']active_storage\/ engine["']/
410
+ end
411
+
412
+ def assert_gems_when_active_storage_is_skipped
413
+ end
414
+
415
+ def assert_dockerfile_when_active_storage_is_skipped
416
+ end
417
+
418
+ def assert_gitattributes_does_not_have_schema_file
419
+ end
420
+
408
421
def fixtures_root
409
422
File . expand_path ( "../fixtures" , __dir__ )
410
423
end
0 commit comments