@@ -50,6 +50,8 @@ def assert_no_file_exists(filename)
50
50
end
51
51
RUBY
52
52
53
+ add_to_env_config "development" , "config.assets.digest = false"
54
+
53
55
require "#{ app_path } /config/environment"
54
56
55
57
get "/assets/demo.js"
@@ -189,7 +191,6 @@ class User < ActiveRecord::Base; raise 'should not be reached'; end
189
191
end
190
192
191
193
test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do
192
- add_to_config "config.assets.digest = true"
193
194
add_to_config "config.action_controller.perform_caching = false"
194
195
195
196
ENV [ "RAILS_ENV" ] = "production"
@@ -202,8 +203,6 @@ class User < ActiveRecord::Base; raise 'should not be reached'; end
202
203
app_file "app/assets/images/rails.png" , "notactuallyapng"
203
204
app_file "app/assets/stylesheets/application.css.erb" , "<%= asset_path('rails.png') %>"
204
205
app_file "app/assets/javascripts/application.js" , "alert();"
205
- # digest is default in false, we must enable it for test environment
206
- add_to_config "config.assets.digest = true"
207
206
208
207
precompile!
209
208
manifest = Dir [ "#{ app_path } /public/assets/manifest-*.json" ] . first
@@ -215,8 +214,6 @@ class User < ActiveRecord::Base; raise 'should not be reached'; end
215
214
216
215
test "the manifest file should be saved by default in the same assets folder" do
217
216
app_file "app/assets/javascripts/application.js" , "alert();"
218
- # digest is default in false, we must enable it for test environment
219
- add_to_config "config.assets.digest = true"
220
217
add_to_config "config.assets.prefix = '/x'"
221
218
222
219
precompile!
@@ -249,7 +246,6 @@ class User < ActiveRecord::Base; raise 'should not be reached'; end
249
246
test "precompile properly refers files referenced with asset_path and runs in the provided RAILS_ENV" do
250
247
app_file "app/assets/images/rails.png" , "notactuallyapng"
251
248
app_file "app/assets/stylesheets/application.css.erb" , "<%= asset_path('rails.png') %>"
252
- # digest is default in false, we must enable it for test environment
253
249
add_to_env_config "test" , "config.assets.digest = true"
254
250
255
251
precompile! ( 'RAILS_ENV=test' )
@@ -281,12 +277,9 @@ class User < ActiveRecord::Base; raise 'should not be reached'; end
281
277
test "precompile appends the md5 hash to files referenced with asset_path and run in production with digest true" do
282
278
app_file "app/assets/images/rails.png" , "notactuallyapng"
283
279
app_file "app/assets/stylesheets/application.css.erb" , "<%= asset_path('rails.png') %>"
284
- add_to_config "config.assets.compile = true"
285
- add_to_config "config.assets.digest = true"
286
280
287
- ENV [ "RAILS_ENV" ] = nil
288
-
289
- precompile! ( 'RAILS_GROUPS=assets' )
281
+ ENV [ "RAILS_ENV" ] = "production"
282
+ precompile!
290
283
291
284
file = Dir [ "#{ app_path } /public/assets/application-*.css" ] . first
292
285
assert_match ( /\/ assets\/ rails-([0-z]+)\. png/ , File . read ( file ) )
@@ -342,6 +335,8 @@ class User < ActiveRecord::Base; raise 'should not be reached'; end
342
335
end
343
336
RUBY
344
337
338
+ add_to_env_config "development" , "config.assets.digest = false"
339
+
345
340
require "#{ app_path } /config/environment"
346
341
347
342
class ::OmgController < ActionController ::Base
@@ -366,6 +361,8 @@ def index
366
361
367
362
app_file "app/assets/javascripts/demo.js" , "alert();"
368
363
364
+ add_to_env_config "development" , "config.assets.digest = false"
365
+
369
366
require "#{ app_path } /config/environment"
370
367
371
368
get "/assets/demo.js"
@@ -395,7 +392,6 @@ class ::PostsController < ActionController::Base ; end
395
392
app_file "app/assets/javascripts/application.js" , "//= require_tree ."
396
393
app_file "app/assets/javascripts/xmlhr.js.erb" , "<%= Post.name %>"
397
394
398
- add_to_config "config.assets.digest = false"
399
395
precompile!
400
396
assert_equal "Post;\n " , File . read ( Dir [ "#{ app_path } /public/assets/application-*.js" ] . first )
401
397
end
@@ -415,7 +411,6 @@ class ::PostsController < ActionController::Base ; end
415
411
test "digested assets are not mistakenly removed" do
416
412
app_file "app/assets/application.js" , "alert();"
417
413
add_to_config "config.assets.compile = true"
418
- add_to_config "config.assets.digest = true"
419
414
420
415
precompile!
421
416
@@ -438,6 +433,7 @@ class ::PostsController < ActionController::Base ; end
438
433
test "asset urls should use the request's protocol by default" do
439
434
app_with_assets_in_view
440
435
add_to_config "config.asset_host = 'example.com'"
436
+ add_to_env_config "development" , "config.assets.digest = false"
441
437
require "#{ app_path } /config/environment"
442
438
class ::PostsController < ActionController ::Base ; end
443
439
@@ -452,6 +448,7 @@ class ::PostsController < ActionController::Base; end
452
448
app_file "app/assets/javascripts/image_loader.js.erb" , "var src='<%= image_path('rails.png') %>';"
453
449
add_to_config "config.assets.precompile = %w{rails.png image_loader.js}"
454
450
add_to_config "config.asset_host = 'example.com'"
451
+ add_to_env_config "development" , "config.assets.digest = false"
455
452
precompile!
456
453
457
454
assert_match "src='//example.com/assets/rails.png'" , File . read ( Dir [ "#{ app_path } /public/assets/image_loader-*.js" ] . first )
@@ -460,9 +457,9 @@ class ::PostsController < ActionController::Base; end
460
457
test "asset paths should use RAILS_RELATIVE_URL_ROOT by default" do
461
458
ENV [ "RAILS_RELATIVE_URL_ROOT" ] = "/sub/uri"
462
459
app_file "app/assets/images/rails.png" , "notreallyapng"
463
-
464
460
app_file "app/assets/javascripts/app.js.erb" , "var src='<%= image_path('rails.png') %>';"
465
461
add_to_config "config.assets.precompile = %w{rails.png app.js}"
462
+ add_to_env_config "development" , "config.assets.digest = false"
466
463
precompile!
467
464
468
465
assert_match "src='/sub/uri/assets/rails.png'" , File . read ( Dir [ "#{ app_path } /public/assets/app-*.js" ] . first )
0 commit comments