aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/asset_tag_helper_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/test/template/asset_tag_helper_test.rb')
-rw-r--r--actionview/test/template/asset_tag_helper_test.rb96
1 files changed, 48 insertions, 48 deletions
diff --git a/actionview/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb
index 1a1b6f5e2d..226bb236c6 100644
--- a/actionview/test/template/asset_tag_helper_test.rb
+++ b/actionview/test/template/asset_tag_helper_test.rb
@@ -1,5 +1,5 @@
-require 'abstract_unit'
-require 'active_support/ordered_options'
+require "abstract_unit"
+require "active_support/ordered_options"
class AssetTagHelperTest < ActionView::TestCase
tests ActionView::Helpers::AssetTagHelper
@@ -13,10 +13,10 @@ class AssetTagHelperTest < ActionView::TestCase
@request = Class.new do
attr_accessor :script_name
- def protocol() 'http://' end
+ def protocol() "http://" end
def ssl?() false end
- def host_with_port() 'localhost' end
- def base_url() 'http://www.example.com' end
+ def host_with_port() "localhost" end
+ def base_url() "http://www.example.com" end
end.new
@controller.request = @request
@@ -306,7 +306,7 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_autodiscovery_link_tag_with_unknown_type
- result = auto_discovery_link_tag(:xml, '/feed.xml', :type => 'application/xml')
+ result = auto_discovery_link_tag(:xml, "/feed.xml", :type => "application/xml")
expected = %(<link href="/feed.xml" rel="alternate" title="XML" type="application/xml" />)
assert_dom_equal expected, result
end
@@ -322,10 +322,10 @@ class AssetTagHelperTest < ActionView::TestCase
def test_asset_path_tag_to_not_create_duplicate_slashes
@controller.config.asset_host = "host/"
- assert_dom_equal('http://host/foo', asset_path("foo"))
+ assert_dom_equal("http://host/foo", asset_path("foo"))
- @controller.config.relative_url_root = '/some/root/'
- assert_dom_equal('http://host/some/root/foo', asset_path("foo"))
+ @controller.config.relative_url_root = "/some/root/"
+ assert_dom_equal("http://host/some/root/foo", asset_path("foo"))
end
def test_compute_asset_public_path
@@ -362,11 +362,11 @@ class AssetTagHelperTest < ActionView::TestCase
def test_javascript_include_tag_with_missing_source
assert_nothing_raised {
- javascript_include_tag('missing_security_guard')
+ javascript_include_tag("missing_security_guard")
}
assert_nothing_raised {
- javascript_include_tag('http://example.com/css/missing_security_guard')
+ javascript_include_tag("http://example.com/css/missing_security_guard")
}
end
@@ -376,13 +376,13 @@ class AssetTagHelperTest < ActionView::TestCase
def test_javascript_include_tag_relative_protocol
@controller.config.asset_host = "assets.example.com"
- assert_dom_equal %(<script src="//assets.example.com/javascripts/prototype.js"></script>), javascript_include_tag('prototype', protocol: :relative)
+ assert_dom_equal %(<script src="//assets.example.com/javascripts/prototype.js"></script>), javascript_include_tag("prototype", protocol: :relative)
end
def test_javascript_include_tag_default_protocol
@controller.config.asset_host = "assets.example.com"
@controller.config.default_asset_host_protocol = :relative
- assert_dom_equal %(<script src="//assets.example.com/javascripts/prototype.js"></script>), javascript_include_tag('prototype')
+ assert_dom_equal %(<script src="//assets.example.com/javascripts/prototype.js"></script>), javascript_include_tag("prototype")
end
def test_stylesheet_path
@@ -407,36 +407,36 @@ class AssetTagHelperTest < ActionView::TestCase
def test_stylesheet_link_tag_with_missing_source
assert_nothing_raised {
- stylesheet_link_tag('missing_security_guard')
+ stylesheet_link_tag("missing_security_guard")
}
assert_nothing_raised {
- stylesheet_link_tag('http://example.com/css/missing_security_guard')
+ stylesheet_link_tag("http://example.com/css/missing_security_guard")
}
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?
+ assert stylesheet_link_tag("dir/file").html_safe?
+ assert stylesheet_link_tag("dir/other/file", "dir/file2").html_safe?
end
def test_stylesheet_link_tag_escapes_options
- assert_dom_equal %(<link href="/file.css" media="&lt;script&gt;" rel="stylesheet" />), stylesheet_link_tag('/file', :media => '<script>')
+ assert_dom_equal %(<link href="/file.css" media="&lt;script&gt;" rel="stylesheet" />), stylesheet_link_tag("/file", :media => "<script>")
end
def test_stylesheet_link_tag_should_not_output_the_same_asset_twice
- assert_dom_equal %(<link href="/stylesheets/wellington.css" media="screen" rel="stylesheet" />\n<link href="/stylesheets/amsterdam.css" media="screen" rel="stylesheet" />), stylesheet_link_tag('wellington', 'wellington', 'amsterdam')
+ assert_dom_equal %(<link href="/stylesheets/wellington.css" media="screen" rel="stylesheet" />\n<link href="/stylesheets/amsterdam.css" media="screen" rel="stylesheet" />), stylesheet_link_tag("wellington", "wellington", "amsterdam")
end
def test_stylesheet_link_tag_with_relative_protocol
@controller.config.asset_host = "assets.example.com"
- assert_dom_equal %(<link href="//assets.example.com/stylesheets/wellington.css" media="screen" rel="stylesheet" />), stylesheet_link_tag('wellington', protocol: :relative)
+ assert_dom_equal %(<link href="//assets.example.com/stylesheets/wellington.css" media="screen" rel="stylesheet" />), stylesheet_link_tag("wellington", protocol: :relative)
end
def test_stylesheet_link_tag_with_default_protocol
@controller.config.asset_host = "assets.example.com"
@controller.config.default_asset_host_protocol = :relative
- assert_dom_equal %(<link href="//assets.example.com/stylesheets/wellington.css" media="screen" rel="stylesheet" />), stylesheet_link_tag('wellington')
+ assert_dom_equal %(<link href="//assets.example.com/stylesheets/wellington.css" media="screen" rel="stylesheet" />), stylesheet_link_tag("wellington")
end
def test_image_path
@@ -456,12 +456,12 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_image_alt
- [nil, '/', '/foo/bar/', 'foo/bar/'].each do |prefix|
- assert_equal 'Rails', image_alt("#{prefix}rails.png")
- assert_equal 'Rails', image_alt("#{prefix}rails-9c0a079bdd7701d7e729bd956823d153.png")
- assert_equal 'Rails', image_alt("#{prefix}rails-f56ef62bc41b040664e801a38f068082a75d506d9048307e8096737463503d0b.png")
- assert_equal 'Long file name with hyphens', image_alt("#{prefix}long-file-name-with-hyphens.png")
- assert_equal 'Long file name with underscores', image_alt("#{prefix}long_file_name_with_underscores.png")
+ [nil, "/", "/foo/bar/", "foo/bar/"].each do |prefix|
+ assert_equal "Rails", image_alt("#{prefix}rails.png")
+ assert_equal "Rails", image_alt("#{prefix}rails-9c0a079bdd7701d7e729bd956823d153.png")
+ assert_equal "Rails", image_alt("#{prefix}rails-f56ef62bc41b040664e801a38f068082a75d506d9048307e8096737463503d0b.png")
+ assert_equal "Long file name with hyphens", image_alt("#{prefix}long-file-name-with-hyphens.png")
+ assert_equal "Long file name with underscores", image_alt("#{prefix}long_file_name_with_underscores.png")
end
end
@@ -470,9 +470,9 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_image_tag_does_not_modify_options
- options = {:size => '16x10'}
- image_tag('icon', options)
- assert_equal({:size => '16x10'}, options)
+ options = {:size => "16x10"}
+ image_tag("icon", options)
+ assert_equal({:size => "16x10"}, options)
end
def test_image_tag_raises_an_error_for_competing_size_arguments
@@ -533,9 +533,9 @@ class AssetTagHelperTest < ActionView::TestCase
def test_video_audio_tag_does_not_modify_options
options = {:autoplay => true}
- video_tag('video', options)
+ video_tag("video", options)
assert_equal({:autoplay => true}, options)
- audio_tag('audio', options)
+ audio_tag("audio", options)
assert_equal({:autoplay => true}, options)
end
@@ -549,7 +549,7 @@ class AssetTagHelperTest < ActionView::TestCase
end
def test_should_not_modify_source_string
- source = '/images/rails.png'
+ source = "/images/rails.png"
copy = source.dup
image_tag(source)
assert_equal copy, source
@@ -557,13 +557,13 @@ class AssetTagHelperTest < ActionView::TestCase
class PlaceholderImage
def blank?; true; end
- def to_s; 'no-image-yet.png'; end
+ def to_s; "no-image-yet.png"; end
end
def test_image_tag_with_blank_placeholder
assert_equal '<img alt="" src="/images/no-image-yet.png" />', image_tag(PlaceholderImage.new, alt: "")
end
def test_image_path_with_blank_placeholder
- assert_equal '/images/no-image-yet.png', image_path(PlaceholderImage.new)
+ assert_equal "/images/no-image-yet.png", image_path(PlaceholderImage.new)
end
def test_image_path_with_asset_host_proc_returning_nil
@@ -708,26 +708,26 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase
end
def test_should_wildcard_asset_host
- @controller.config.asset_host = 'http://a%d.example.com'
+ @controller.config.asset_host = "http://a%d.example.com"
assert_match(%r(http://a[0123].example.com), compute_asset_host("foo"))
end
def test_should_wildcard_asset_host_between_zero_and_four
- @controller.config.asset_host = 'http://a%d.example.com'
- assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png'))
- assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_url('xml.png'))
+ @controller.config.asset_host = "http://a%d.example.com"
+ assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path("xml.png"))
+ assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_url("xml.png"))
end
def test_asset_host_without_protocol_should_be_protocol_relative
- @controller.config.asset_host = 'a.example.com'
- assert_equal 'gopher://a.example.com/collaboration/hieraki/images/xml.png', image_path('xml.png')
- assert_equal 'gopher://a.example.com/collaboration/hieraki/images/xml.png', image_url('xml.png')
+ @controller.config.asset_host = "a.example.com"
+ assert_equal "gopher://a.example.com/collaboration/hieraki/images/xml.png", image_path("xml.png")
+ assert_equal "gopher://a.example.com/collaboration/hieraki/images/xml.png", image_url("xml.png")
end
def test_asset_host_without_protocol_should_be_protocol_relative_even_if_path_present
- @controller.config.asset_host = 'a.example.com/files/go/here'
- assert_equal 'gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png', image_path('xml.png')
- assert_equal 'gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png', image_url('xml.png')
+ @controller.config.asset_host = "a.example.com/files/go/here"
+ assert_equal "gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png", image_path("xml.png")
+ assert_equal "gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png", image_url("xml.png")
end
def test_assert_css_and_js_of_the_same_name_return_correct_extension
@@ -747,10 +747,10 @@ class AssetUrlHelperControllerTest < ActionView::TestCase
@request = Class.new do
attr_accessor :script_name
- def protocol() 'http://' end
+ def protocol() "http://" end
def ssl?() false end
- def host_with_port() 'www.example.com' end
- def base_url() 'http://www.example.com' end
+ def host_with_port() "www.example.com" end
+ def base_url() "http://www.example.com" end
end.new
@controller.request = @request