aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/asset_tag_helper_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2017-11-28 14:56:47 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2017-11-28 14:56:47 -0500
commit61214632f4a5d21ef86803740b6e30627e96c475 (patch)
treed041334e7c2cf515564984d8ee8bb6dee6968e23 /actionview/test/template/asset_tag_helper_test.rb
parent2837d0f3347e747a8c12bd3c097bc7282072d42b (diff)
downloadrails-61214632f4a5d21ef86803740b6e30627e96c475.tar.gz
rails-61214632f4a5d21ef86803740b6e30627e96c475.tar.bz2
rails-61214632f4a5d21ef86803740b6e30627e96c475.zip
Make sure the request exist befoe trying to send early hints
Action Mailer context for example responds to request but don't have a a request object. Fixes #31265
Diffstat (limited to 'actionview/test/template/asset_tag_helper_test.rb')
-rw-r--r--actionview/test/template/asset_tag_helper_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/actionview/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb
index 7475f5cc3c..a8b66191bc 100644
--- a/actionview/test/template/asset_tag_helper_test.rb
+++ b/actionview/test/template/asset_tag_helper_test.rb
@@ -440,6 +440,14 @@ class AssetTagHelperTest < ActionView::TestCase
}
end
+ def test_stylesheet_link_tag_without_request
+ @request = nil
+ assert_dom_equal(
+ %(<link rel="stylesheet" media="screen" href="/stylesheets/foo.css" />),
+ stylesheet_link_tag("foo.css")
+ )
+ end
+
def test_stylesheet_link_tag_is_html_safe
assert stylesheet_link_tag("dir/file").html_safe?
assert stylesheet_link_tag("dir/other/file", "dir/file2").html_safe?
@@ -464,6 +472,11 @@ class AssetTagHelperTest < ActionView::TestCase
assert_dom_equal %(<link href="//assets.example.com/stylesheets/wellington.css" media="screen" rel="stylesheet" />), stylesheet_link_tag("wellington")
end
+ def test_javascript_include_tag_without_request
+ @request = nil
+ assert_dom_equal %(<script src="/javascripts/foo.js"></script>), javascript_include_tag("foo.js")
+ end
+
def test_image_path
ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
end
@@ -778,6 +791,23 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase
end
end
+class AssetTagHelperWithoutRequestTest < ActionView::TestCase
+ tests ActionView::Helpers::AssetTagHelper
+
+ undef :request
+
+ def test_stylesheet_link_tag_without_request
+ assert_dom_equal(
+ %(<link rel="stylesheet" media="screen" href="/stylesheets/foo.css" />),
+ stylesheet_link_tag("foo.css")
+ )
+ end
+
+ def test_javascript_include_tag_without_request
+ assert_dom_equal %(<script src="/javascripts/foo.js"></script>), javascript_include_tag("foo.js")
+ end
+end
+
class AssetUrlHelperControllerTest < ActionView::TestCase
tests ActionView::Helpers::AssetUrlHelper