diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/asset_debugging_test.rb | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index 1d27cecd3c..e6a660cf25 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -72,23 +72,23 @@ module ApplicationTests test "public path and tag methods are not over-written by the asset pipeline" do contents = "doesnotexist" cases = { - public_asset_path: %r{/#{ contents }}, - public_image_path: %r{/images/#{ contents }}, - public_video_path: %r{/videos/#{ contents }}, - public_audio_path: %r{/audios/#{ contents }}, - public_font_path: %r{/fonts/#{ contents }}, - public_javascript_path: %r{/javascripts/#{ contents }}, - public_stylesheet_path: %r{/stylesheets/#{ contents }}, - public_image_tag: %r{<img src="/images/#{ contents }"}, - public_favicon_link_tag: %r{<link rel="shortcut icon" type="image/x-icon" href="/images/#{ contents }" />}, - public_stylesheet_link_tag: %r{<link rel="stylesheet" media="screen" href="/stylesheets/#{ contents }.css" />}, - public_javascript_include_tag: %r{<script src="/javascripts/#{ contents }.js">}, - public_audio_tag: %r{<audio src="/audios/#{ contents }"></audio>}, - public_video_tag: %r{<video src="/videos/#{ contents }"></video>} + asset_path: %r{/#{ contents }}, + image_path: %r{/images/#{ contents }}, + video_path: %r{/videos/#{ contents }}, + audio_path: %r{/audios/#{ contents }}, + font_path: %r{/fonts/#{ contents }}, + javascript_path: %r{/javascripts/#{ contents }}, + stylesheet_path: %r{/stylesheets/#{ contents }}, + image_tag: %r{<img src="/images/#{ contents }"}, + favicon_link_tag: %r{<link rel="shortcut icon" type="image/x-icon" href="/images/#{ contents }" />}, + stylesheet_link_tag: %r{<link rel="stylesheet" media="screen" href="/stylesheets/#{ contents }.css" />}, + javascript_include_tag: %r{<script src="/javascripts/#{ contents }.js">}, + audio_tag: %r{<audio src="/audios/#{ contents }"></audio>}, + video_tag: %r{<video src="/videos/#{ contents }"></video>} } cases.each do |(view_method, tag_match)| - app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}' %>" + app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}', public_folder: true %>" app "development" @@ -104,17 +104,17 @@ module ApplicationTests test "public url methods are not over-written by the asset pipeline" do contents = "doesnotexist" cases = { - public_asset_url: %r{http://example.org/#{ contents }}, - public_image_url: %r{http://example.org/images/#{ contents }}, - public_video_url: %r{http://example.org/videos/#{ contents }}, - public_audio_url: %r{http://example.org/audios/#{ contents }}, - public_font_url: %r{http://example.org/fonts/#{ contents }}, - public_javascript_url: %r{http://example.org/javascripts/#{ contents }}, - public_stylesheet_url: %r{http://example.org/stylesheets/#{ contents }}, + asset_url: %r{http://example.org/#{ contents }}, + image_url: %r{http://example.org/images/#{ contents }}, + video_url: %r{http://example.org/videos/#{ contents }}, + audio_url: %r{http://example.org/audios/#{ contents }}, + font_url: %r{http://example.org/fonts/#{ contents }}, + javascript_url: %r{http://example.org/javascripts/#{ contents }}, + stylesheet_url: %r{http://example.org/stylesheets/#{ contents }}, } cases.each do |(view_method, tag_match)| - app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}' %>" + app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}', public_folder: true %>" app "development" @@ -127,10 +127,29 @@ module ApplicationTests end end - test "public path methods do not use the asset pipeline" do + test "{ public_folder: true } does not use the asset pipeline" do cases = { - asset_path: /\/assets\/application-.*.\.js/, - public_asset_path: /application.js/, + /\/assets\/application-.*.\.js/ => {}, + /application.js/ => { public_folder: true}, + } + cases.each do |(tag_match, options_hash)| + app_file "app/views/posts/index.html.erb", "<%= asset_path('application.js', #{ options_hash }) %>" + + app "development" + + class ::PostsController < ActionController::Base ; end + + get "/posts?debug_assets=true" + + body = last_response.body.strip + assert_match(tag_match, body, "Expected `asset_path` with `#{ options_hash}` to produce a match to #{ tag_match }, but did not: #{ body }") + end + end + + test "public_compute_asset_path does not use the asset pipeline" do + cases = { + compute_asset_path: /\/assets\/application-.*.\.js/, + public_compute_asset_path: /application.js/, } cases.each do |(view_method, tag_match)| |