class AssetTagHelperNonVhostTest

Attributes

request[R]

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File actionview/test/template/asset_tag_helper_test.rb, line 625
def setup
  super
  @controller = BasicController.new
  @controller.config.relative_url_root = "/collaboration/hieraki"

  @request = Struct.new(:protocol, :base_url).new("gopher://", "gopher://www.example.com")
  @controller.request = @request
end
test_assert_css_and_js_of_the_same_name_return_correct_extension() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 746
def test_assert_css_and_js_of_the_same_name_return_correct_extension
  assert_dom_equal(%(/collaboration/hieraki/javascripts/foo.js), javascript_path("foo"))
  assert_dom_equal(%(/collaboration/hieraki/stylesheets/foo.css), stylesheet_path("foo"))
end
test_asset_host_without_protocol_should_be_protocol_relative() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 734
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")
end
test_asset_host_without_protocol_should_be_protocol_relative_even_if_path_present() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 740
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")
end
test_should_compute_proper_path() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 638
def test_should_compute_proper_path
  assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag)
  assert_dom_equal(%(/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
  assert_dom_equal(%(/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
  assert_dom_equal(%(/collaboration/hieraki/images/xml.png), image_path("xml.png"))
end
test_should_compute_proper_path_with_asset_host() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 676
def test_should_compute_proper_path_with_asset_host
  @controller.config.asset_host = "assets.example.com"
  assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag)
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png"))
end
test_should_compute_proper_path_with_asset_host_and_default_protocol() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 684
def test_should_compute_proper_path_with_asset_host_and_default_protocol
  @controller.config.asset_host = "assets.example.com"
  @controller.config.default_asset_host_protocol = :request
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png"))
end
test_should_compute_proper_url_with_asset_host() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 692
def test_should_compute_proper_url_with_asset_host
  @controller.config.asset_host = "assets.example.com"
  assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag)
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_url("xmlhr"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_url("style"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/images/xml.png), image_url("xml.png"))
end
test_should_compute_proper_url_with_asset_host_and_default_protocol() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 700
def test_should_compute_proper_url_with_asset_host_and_default_protocol
  @controller.config.asset_host = "assets.example.com"
  @controller.config.default_asset_host_protocol = :request
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_url("xmlhr"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_url("style"))
  assert_dom_equal(%(gopher://assets.example.com/collaboration/hieraki/images/xml.png), image_url("xml.png"))
end
test_should_current_request_host_is_always_returned_for_request() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 649
def test_should_current_request_host_is_always_returned_for_request
  assert_equal "gopher://www.example.com", compute_asset_host("foo", protocol: :request)
end
test_should_ignore_asset_host_on_complete_url() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 713
def test_should_ignore_asset_host_on_complete_url
  @controller.config.asset_host = "http://assets.example.com"
  assert_dom_equal(%(<link href="http://bar.example.com/stylesheets/style.css" media="screen" rel="stylesheet" />), stylesheet_link_tag("http://bar.example.com/stylesheets/style.css"))
end
test_should_ignore_asset_host_on_scheme_relative_url() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 718
def test_should_ignore_asset_host_on_scheme_relative_url
  @controller.config.asset_host = "http://assets.example.com"
  assert_dom_equal(%(<link href="//bar.example.com/stylesheets/style.css" media="screen" rel="stylesheet" />), stylesheet_link_tag("//bar.example.com/stylesheets/style.css"))
end
test_should_ignore_relative_root_path_on_complete_url() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 657
def test_should_ignore_relative_root_path_on_complete_url
  assert_dom_equal(%(http://www.example.com/images/xml.png), image_path("http://www.example.com/images/xml.png"))
end
test_should_return_asset_host_with_protocol() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 708
def test_should_return_asset_host_with_protocol
  @controller.config.asset_host = "http://assets.example.com"
  assert_equal "http://assets.example.com", compute_asset_host("foo")
end
test_should_return_custom_host_if_passed_in_options() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 653
def test_should_return_custom_host_if_passed_in_options
  assert_equal "http://custom.example.com", compute_asset_host("foo", host: "http://custom.example.com")
end
test_should_return_custom_protocol_asset_host() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 671
def test_should_return_custom_protocol_asset_host
  @controller.config.asset_host = "assets.example.com"
  assert_equal "ftp://assets.example.com", compute_asset_host("foo", protocol: "ftp")
end
test_should_return_nothing_if_asset_host_isnt_configured() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 645
def test_should_return_nothing_if_asset_host_isnt_configured
  assert_nil compute_asset_host("foo")
end
test_should_return_relative_asset_host() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 666
def test_should_return_relative_asset_host
  @controller.config.asset_host = "assets.example.com"
  assert_equal "//assets.example.com", compute_asset_host("foo", protocol: :relative)
end
test_should_return_simple_string_asset_host() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 661
def test_should_return_simple_string_asset_host
  @controller.config.asset_host = "assets.example.com"
  assert_equal "gopher://assets.example.com", compute_asset_host("foo")
end
test_should_wildcard_asset_host() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 723
def test_should_wildcard_asset_host
  @controller.config.asset_host = "http://a%d.example.com"
  assert_match(%r(http://a[0123]\.example\.com), compute_asset_host("foo"))
end
test_should_wildcard_asset_host_between_zero_and_four() click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 728
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"))
end
url_for(options) click to toggle source
# File actionview/test/template/asset_tag_helper_test.rb, line 634
def url_for(options)
  "http://www.example.com/collaboration/hieraki"
end