diff options
author | schneems <richard.schneeman@gmail.com> | 2016-06-15 14:16:21 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2016-08-29 13:16:07 -0500 |
commit | 0a633b324eb8239a467fa7fbb9fa18abcd5759d3 (patch) | |
tree | 775bfe2ba3639f23bd95c5680a6b638a740fab1e /railties | |
parent | e8b081133a6780b37d1143becf4cfc945c41cb49 (diff) | |
download | rails-0a633b324eb8239a467fa7fbb9fa18abcd5759d3.tar.gz rails-0a633b324eb8239a467fa7fbb9fa18abcd5759d3.tar.bz2 rails-0a633b324eb8239a467fa7fbb9fa18abcd5759d3.zip |
Test `public_` methods.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/asset_debugging_test.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index a732869d62..92d10ec827 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -68,5 +68,77 @@ module ApplicationTests assert_match(/<script src="\/assets\/application(\.self)?-([0-z]+)\.js\?body=1"><\/script>/, last_response.body) assert_match(/<script src="\/assets\/xmlhr(\.self)?-([0-z]+)\.js\?body=1"><\/script>/, last_response.body) end + + test "public path 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 }}, + } + + cases.each do |(view_method, tag_match)| + app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}' %>" + + app "development" + + class ::PostsController < ActionController::Base ; end + + get '/posts?debug_assets=true' + + body = last_response.body + assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{ tag_match }, but did not: #{ body }") + end + end + + 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 }}, + } + + cases.each do |(view_method, tag_match)| + app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}' %>" + + app "development" + + class ::PostsController < ActionController::Base ; end + + get '/posts?debug_assets=true' + + body = last_response.body + assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{ tag_match }, but did not: #{ body }") + end + end + + test "public path methods do not use the asset pipeline" do + cases = { + asset_path: /\/assets\/application-.*.\.js/, + public_asset_path: /application.js/ + } + + cases.each do |(view_method, tag_match)| + app_file "app/views/posts/index.html.erb", "<%= #{ view_method } 'application.js' %>" + + app "development" + + class ::PostsController < ActionController::Base ; end + + get '/posts?debug_assets=true' + + body = last_response.body.strip + assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{ tag_match }, but did not: #{ body }") + end + end end end |