Upgraded Rails and RSpec
[monkeycharger.git] / vendor / rails / actionpack / test / template / asset_tag_helper_test.rb
bloba27a597e98c38292347a2db1687f0bc231684435
1 require "#{File.dirname(__FILE__)}/../abstract_unit"
3 class AssetTagHelperTest < Test::Unit::TestCase
4   include ActionView::Helpers::TagHelper
5   include ActionView::Helpers::UrlHelper
6   include ActionView::Helpers::AssetTagHelper
8   def setup
9     silence_warnings do
10       ActionView::Helpers::AssetTagHelper.send(
11         :const_set,
12         :JAVASCRIPTS_DIR,
13         File.dirname(__FILE__) + "/../fixtures/public/javascripts"
14       )
16       ActionView::Helpers::AssetTagHelper.send(
17         :const_set,
18         :STYLESHEETS_DIR,
19         File.dirname(__FILE__) + "/../fixtures/public/stylesheets"
20       )
22       ActionView::Helpers::AssetTagHelper.send(
23         :const_set,
24         :ASSETS_DIR,
25         File.dirname(__FILE__) + "/../fixtures/public"
26       )
27     end
29     @controller = Class.new do
30       attr_accessor :request
31       def url_for(*args) "http://www.example.com" end
32     end.new
34     @request = Class.new do
35       def relative_url_root() "" end
36       def protocol() 'http://' end
37     end.new
39     @controller.request = @request
41     ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
43     ActionView::Base.computed_public_paths.clear
44   end
46   def teardown
47     ActionController::Base.perform_caching = false
48     ActionController::Base.asset_host = nil
49     ENV["RAILS_ASSET_ID"] = nil
50   end
52   AutoDiscoveryToTag = {
53     %(auto_discovery_link_tag) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />),
54     %(auto_discovery_link_tag(:rss)) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />),
55     %(auto_discovery_link_tag(:atom)) => %(<link href="http://www.example.com" rel="alternate" title="ATOM" type="application/atom+xml" />),
56     %(auto_discovery_link_tag(:xml)) => %(<link href="http://www.example.com" rel="alternate" title="XML" type="application/xml" />),
57     %(auto_discovery_link_tag(:rss, :action => "feed")) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />),
58     %(auto_discovery_link_tag(:rss, "http://localhost/feed")) => %(<link href="http://localhost/feed" rel="alternate" title="RSS" type="application/rss+xml" />),
59     %(auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />),
60     %(auto_discovery_link_tag(:rss, {}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />),
61     %(auto_discovery_link_tag(nil, {}, {:type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="" type="text/html" />),
62     %(auto_discovery_link_tag(nil, {}, {:title => "No stream.. really", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="No stream.. really" type="text/html" />),
63     %(auto_discovery_link_tag(:rss, {}, {:title => "My RSS", :type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="text/html" />),
64     %(auto_discovery_link_tag(:atom, {}, {:rel => "Not so alternate"})) => %(<link href="http://www.example.com" rel="Not so alternate" title="ATOM" type="application/atom+xml" />),
65   }
67   JavascriptPathToTag = {
68     %(javascript_path("xmlhr")) => %(/javascripts/xmlhr.js),
69     %(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js),
70     %(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.js)
71   }
73   PathToJavascriptToTag = {
74     %(path_to_javascript("xmlhr")) => %(/javascripts/xmlhr.js),
75     %(path_to_javascript("super/xmlhr")) => %(/javascripts/super/xmlhr.js),
76     %(path_to_javascript("/super/xmlhr.js")) => %(/super/xmlhr.js)
77   }
79   JavascriptIncludeToTag = {
80     %(javascript_include_tag("xmlhr")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>),
81     %(javascript_include_tag("xmlhr.js")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>),
82     %(javascript_include_tag("xmlhr", :lang => "vbscript")) => %(<script lang="vbscript" src="/javascripts/xmlhr.js" type="text/javascript"></script>),
83     %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/elsewhere/cools.js" type="text/javascript"></script>),
84     %(javascript_include_tag(:defaults)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>),
85     %(javascript_include_tag(:all)) => %(<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>),
86     %(javascript_include_tag(:defaults, "test")) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/test.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>),
87     %(javascript_include_tag("test", :defaults)) => %(<script src="/javascripts/test.js" type="text/javascript"></script>\n<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>)
88   }
90   StylePathToTag = {
91     %(stylesheet_path("style")) => %(/stylesheets/style.css),
92     %(stylesheet_path("style.css")) => %(/stylesheets/style.css),
93     %(stylesheet_path('dir/file')) => %(/stylesheets/dir/file.css),
94     %(stylesheet_path('/dir/file.rcss')) => %(/dir/file.rcss)
95   }
97   PathToStyleToTag = {
98     %(path_to_stylesheet("style")) => %(/stylesheets/style.css),
99     %(path_to_stylesheet("style.css")) => %(/stylesheets/style.css),
100     %(path_to_stylesheet('dir/file')) => %(/stylesheets/dir/file.css),
101     %(path_to_stylesheet('/dir/file.rcss')) => %(/dir/file.rcss)
102   }
104   StyleLinkToTag = {
105     %(stylesheet_link_tag("style")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />),
106     %(stylesheet_link_tag("style.css")) => %(<link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />),
107     %(stylesheet_link_tag("/dir/file")) => %(<link href="/dir/file.css" media="screen" rel="stylesheet" type="text/css" />),
108     %(stylesheet_link_tag("dir/file")) => %(<link href="/stylesheets/dir/file.css" media="screen" rel="stylesheet" type="text/css" />),
109     %(stylesheet_link_tag("style", :media => "all")) => %(<link href="/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />),
110     %(stylesheet_link_tag(:all)) => %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />),
111     %(stylesheet_link_tag(:all, :media => "all")) => %(<link href="/stylesheets/bank.css" media="all" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="all" rel="stylesheet" type="text/css" />),
112     %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="stylesheet" type="text/css" />),
113     %(stylesheet_link_tag("http://www.example.com/styles/style")) => %(<link href="http://www.example.com/styles/style.css" media="screen" rel="stylesheet" type="text/css" />)
114   }
116   ImagePathToTag = {
117     %(image_path("xml"))          => %(/images/xml),
118     %(image_path("xml.png"))      => %(/images/xml.png),
119     %(image_path("dir/xml.png"))  => %(/images/dir/xml.png),
120     %(image_path("/dir/xml.png")) => %(/dir/xml.png)    
121   }
123   PathToImageToTag = {
124     %(path_to_image("xml"))          => %(/images/xml),
125     %(path_to_image("xml.png"))      => %(/images/xml.png),
126     %(path_to_image("dir/xml.png"))  => %(/images/dir/xml.png),
127     %(path_to_image("/dir/xml.png")) => %(/dir/xml.png)
128   }
130   ImageLinkToTag = {
131     %(image_tag("xml.png")) => %(<img alt="Xml" src="/images/xml.png" />),
132     %(image_tag("rss.gif", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.gif" />),
133     %(image_tag("gold.png", :size => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />),
134     %(image_tag("gold.png", "size" => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />),
135     %(image_tag("error.png", "size" => "45")) => %(<img alt="Error" src="/images/error.png" />),
136     %(image_tag("error.png", "size" => "45 x 70")) => %(<img alt="Error" src="/images/error.png" />),
137     %(image_tag("error.png", "size" => "x")) => %(<img alt="Error" src="/images/error.png" />),
138     %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />),
139     %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />),
140     %(image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />),
141     %(image_tag("mouse.png", :mouseover => image_path("mouse_over.png"))) => %(<img alt="Mouse" onmouseover="this.src='/images/mouse_over.png'" onmouseout="this.src='/images/mouse.png'" src="/images/mouse.png" />)
142   }
145   def test_auto_discovery_link_tag
146     AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
147   end
149   def test_javascript_path
150     JavascriptPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
151   end
153   def test_path_to_javascript_alias_for_javascript_path
154     PathToJavascriptToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
155   end
157   def test_javascript_include_tag
158     ENV["RAILS_ASSET_ID"] = ""
159     JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
161     ActionView::Base.computed_public_paths.clear
163     ENV["RAILS_ASSET_ID"] = "1"
164     assert_dom_equal(%(<script src="/javascripts/prototype.js?1" type="text/javascript"></script>\n<script src="/javascripts/effects.js?1" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js?1" type="text/javascript"></script>\n<script src="/javascripts/controls.js?1" type="text/javascript"></script>\n<script src="/javascripts/application.js?1" type="text/javascript"></script>), javascript_include_tag(:defaults))
165   end
167   def test_register_javascript_include_default
168     ENV["RAILS_ASSET_ID"] = ""
169     ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider'
170     assert_dom_equal  %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag(:defaults)
171     ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2'
172     assert_dom_equal  %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/elsewhere/blub/lib2.js" type="text/javascript"></script>\n<script src="/javascripts/application.js" type="text/javascript"></script>), javascript_include_tag(:defaults)
173   end
174   
175   def test_stylesheet_path
176     StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
177   end
179   def test_path_to_stylesheet_alias_for_stylesheet_path
180     PathToStyleToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
181   end
183   def test_stylesheet_link_tag
184     ENV["RAILS_ASSET_ID"] = ""
185     StyleLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
186   end
188   def test_image_path
189     ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
190   end
191   
192   def test_path_to_image_alias_for_image_path
193     PathToImageToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
194   end
196   def test_image_tag
197     ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
198   end
199   
200   def test_timebased_asset_id
201     expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s
202     assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png")
203   end
205   def test_should_skip_asset_id_on_complete_url
206     assert_equal %(<img alt="Rails" src="http://www.example.com/rails.png" />), image_tag("http://www.example.com/rails.png")
207   end
208   
209   def test_should_use_preset_asset_id
210     ENV["RAILS_ASSET_ID"] = "4500"
211     assert_equal %(<img alt="Rails" src="/images/rails.png?4500" />), image_tag("rails.png")
212   end
214   def test_preset_empty_asset_id
215     ENV["RAILS_ASSET_ID"] = ""
216     assert_equal %(<img alt="Rails" src="/images/rails.png" />), image_tag("rails.png")
217   end
219   def test_should_not_modify_source_string
220     source = '/images/rails.png'
221     copy = source.dup
222     image_tag(source)
223     assert_equal copy, source
224   end
227   def test_caching_javascript_include_tag_when_caching_on
228     ENV["RAILS_ASSET_ID"] = ""
229     ActionController::Base.asset_host = 'http://a%d.example.com'
230     ActionController::Base.perform_caching = true
231     
232     assert_dom_equal(
233       %(<script src="http://a0.example.com/javascripts/all.js" type="text/javascript"></script>),
234       javascript_include_tag(:all, :cache => true)
235     )
237     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
238     
239     assert_dom_equal(
240       %(<script src="http://a2.example.com/javascripts/money.js" type="text/javascript"></script>),
241       javascript_include_tag(:all, :cache => "money")
242     )
244     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
246   ensure
247     File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
248     File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
249   end
250   
251   def test_caching_javascript_include_tag_when_caching_on_and_using_subdirectory
252     ENV["RAILS_ASSET_ID"] = ""
253     ActionController::Base.asset_host = 'http://a%d.example.com'
254     ActionController::Base.perform_caching = true
256     assert_dom_equal(
257       %(<script src="http://a3.example.com/javascripts/cache/money.js" type="text/javascript"></script>),
258       javascript_include_tag(:all, :cache => "cache/money")
259     )
261     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js'))
262   ensure
263     File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js'))
264   end
265   
266   def test_caching_javascript_include_tag_when_caching_off
267     ENV["RAILS_ASSET_ID"] = ""
268     ActionController::Base.perform_caching = false
269     
270     assert_dom_equal(
271       %(<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>),
272       javascript_include_tag(:all, :cache => true)
273     )
275     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
276     
277     assert_dom_equal(
278       %(<script src="/javascripts/application.js" type="text/javascript"></script>\n<script src="/javascripts/bank.js" type="text/javascript"></script>\n<script src="/javascripts/robber.js" type="text/javascript"></script>),
279       javascript_include_tag(:all, :cache => "money")
280     )
282     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
283   end
285   def test_caching_stylesheet_link_tag_when_caching_on
286     ENV["RAILS_ASSET_ID"] = ""
287     ActionController::Base.asset_host = 'http://a%d.example.com'
288     ActionController::Base.perform_caching = true
289     
290     assert_dom_equal(
291       %(<link href="http://a3.example.com/stylesheets/all.css" media="screen" rel="stylesheet" type="text/css" />),
292       stylesheet_link_tag(:all, :cache => true)
293     )
295     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
297     assert_dom_equal(
298       %(<link href="http://a3.example.com/stylesheets/money.css" media="screen" rel="stylesheet" type="text/css" />),
299       stylesheet_link_tag(:all, :cache => "money")
300     )
302     assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
303   ensure
304     File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
305     File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
306   end
307   
308   def test_caching_stylesheet_include_tag_when_caching_off
309     ENV["RAILS_ASSET_ID"] = ""
310     ActionController::Base.perform_caching = false
311     
312     assert_dom_equal(
313       %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />),
314       stylesheet_link_tag(:all, :cache => true)
315     )
317     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
318     
319     assert_dom_equal(
320       %(<link href="/stylesheets/bank.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />),
321       stylesheet_link_tag(:all, :cache => "money")
322     )
324     assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
325   end
328 class AssetTagHelperNonVhostTest < Test::Unit::TestCase
329   include ActionView::Helpers::TagHelper
330   include ActionView::Helpers::UrlHelper
331   include ActionView::Helpers::AssetTagHelper
333   def setup
334     @controller = Class.new do
335       attr_accessor :request
337       def url_for(options)
338         "http://www.example.com/collaboration/hieraki"
339       end
340     end.new
341     
342     @request = Class.new do 
343       def relative_url_root
344         "/collaboration/hieraki"
345       end
347       def protocol
348         'gopher://'
349       end
350     end.new
351     
352     @controller.request = @request
353     
354     ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
355   end
357   def test_should_compute_proper_path
358     assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag)
359     assert_dom_equal(%(/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
360     assert_dom_equal(%(/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
361     assert_dom_equal(%(/collaboration/hieraki/images/xml.png), image_path("xml.png"))
362   end
363   
364   def test_should_ignore_relative_root_path_on_complete_url
365     assert_dom_equal(%(http://www.example.com/images/xml.png), image_path("http://www.example.com/images/xml.png"))
366   end
368   def test_should_compute_proper_path_with_asset_host
369     ActionController::Base.asset_host = "http://assets.example.com"
370     assert_dom_equal(%(<link href="http://www.example.com/collaboration/hieraki" rel="alternate" title="RSS" type="application/rss+xml" />), auto_discovery_link_tag)
371     assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
372     assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
373     assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png"))
374   ensure
375     ActionController::Base.asset_host = ""
376   end
378   def test_should_ignore_asset_host_on_complete_url
379     ActionController::Base.asset_host = "http://assets.example.com"
380     assert_dom_equal(%(<link href="http://bar.example.com/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />), stylesheet_link_tag("http://bar.example.com/stylesheets/style.css"))
381   ensure
382     ActionController::Base.asset_host = ""
383   end
385   def test_should_wildcard_asset_host_between_zero_and_four
386     ActionController::Base.asset_host = 'http://a%d.example.com'
387     assert_match %r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png')
388   ensure
389     ActionController::Base.asset_host = nil
390   end
392   def test_asset_host_without_protocol_should_use_request_protocol
393     ActionController::Base.asset_host = 'a.example.com'
394     assert_equal 'gopher://a.example.com/collaboration/hieraki/images/xml.png', image_path('xml.png')
395   ensure
396     ActionController::Base.asset_host = nil
397   end
399   def test_asset_host_without_protocol_should_use_request_protocol_even_if_path_present
400     ActionController::Base.asset_host = 'a.example.com/files/go/here'
401     assert_equal 'gopher://a.example.com/files/go/here/collaboration/hieraki/images/xml.png', image_path('xml.png')
402   ensure
403     ActionController::Base.asset_host = nil
404   end