mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix tests from rails.png removal.
I'm giving @jlsuttles credit on this commit because she gave me the idea
and the actual converted image in 952289aabf
.
This commit is contained in:
parent
50fd48e261
commit
c959798571
1 changed files with 8 additions and 1 deletions
|
@ -41,6 +41,7 @@ module ApplicationTests
|
|||
end
|
||||
|
||||
test "assets routes have higher priority" do
|
||||
app_file "app/assets/images/rails.png", "notactuallyapng"
|
||||
app_file "app/assets/javascripts/demo.js.erb", "a = <%= image_path('rails.png').inspect %>;"
|
||||
|
||||
app_file 'config/routes.rb', <<-RUBY
|
||||
|
@ -222,6 +223,7 @@ module ApplicationTests
|
|||
end
|
||||
|
||||
test "precompile properly refers files referenced with asset_path and runs in the provided RAILS_ENV" do
|
||||
app_file "app/assets/images/rails.png", "notactuallyapng"
|
||||
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
|
||||
# digest is default in false, we must enable it for test environment
|
||||
add_to_env_config "test", "config.assets.digest = true"
|
||||
|
@ -233,6 +235,8 @@ module ApplicationTests
|
|||
end
|
||||
|
||||
test "precompile shouldn't use the digests present in manifest.json" do
|
||||
app_file "app/assets/images/rails.png", "notactuallyapng"
|
||||
|
||||
app_file "app/assets/stylesheets/application.css.erb", "//= depend_on rails.png\np { url: <%= asset_path('rails.png') %> }"
|
||||
|
||||
ENV["RAILS_ENV"] = "production"
|
||||
|
@ -251,6 +255,7 @@ module ApplicationTests
|
|||
end
|
||||
|
||||
test "precompile appends the md5 hash to files referenced with asset_path and run in production with digest true" do
|
||||
app_file "app/assets/images/rails.png", "notactuallyapng"
|
||||
app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>"
|
||||
add_to_config "config.assets.compile = true"
|
||||
add_to_config "config.assets.digest = true"
|
||||
|
@ -272,7 +277,7 @@ module ApplicationTests
|
|||
|
||||
manifest = Dir["#{app_path}/public/assets/manifest-*.json"].first
|
||||
assets = ActiveSupport::JSON.decode(File.read(manifest))
|
||||
assert asset_path = assets["assets"].find { |(k, _)| k !~ /rails.png/ && k =~ /.png/ }[1]
|
||||
assert asset_path = assets["assets"].find { |(k, _)| k && k =~ /.png/ }[1]
|
||||
|
||||
require "#{app_path}/config/environment"
|
||||
|
||||
|
@ -431,6 +436,7 @@ module ApplicationTests
|
|||
end
|
||||
|
||||
test "asset urls should be protocol-relative if no request is in scope" do
|
||||
app_file "app/assets/images/rails.png", "notreallyapng"
|
||||
app_file "app/assets/javascripts/image_loader.js.erb", 'var src="<%= image_path("rails.png") %>";'
|
||||
add_to_config "config.assets.precompile = %w{image_loader.js}"
|
||||
add_to_config "config.asset_host = 'example.com'"
|
||||
|
@ -441,6 +447,7 @@ module ApplicationTests
|
|||
|
||||
test "asset paths should use RAILS_RELATIVE_URL_ROOT by default" do
|
||||
ENV["RAILS_RELATIVE_URL_ROOT"] = "/sub/uri"
|
||||
app_file "app/assets/images/rails.png", "notreallyapng"
|
||||
|
||||
app_file "app/assets/javascripts/app.js.erb", 'var src="<%= image_path("rails.png") %>";'
|
||||
add_to_config "config.assets.precompile = %w{app.js}"
|
||||
|
|
Loading…
Reference in a new issue