Changeset 6187
- Timestamp:
- 02/21/07 15:28:37 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_view/helpers/asset_tag_helper.rb
r6164 r6187 149 149 if !File.exists?(joined_javascript_path) 150 150 File.open(joined_javascript_path, "w+") do |cache| 151 javascript_paths = expand_javascript_sources(sources).collect { |source| javascript_path(source) } 151 javascript_paths = expand_javascript_sources(sources).collect do |source| 152 compute_public_path(source, 'javascripts', 'js', false) 153 end 154 152 155 cache.write(join_asset_file_contents(javascript_paths)) 153 156 end … … 241 244 if !File.exists?(joined_stylesheet_path) 242 245 File.open(joined_stylesheet_path, "w+") do |cache| 243 stylesheet_paths = expand_stylesheet_sources(sources).collect { |source| stylesheet_path(source) } 246 stylesheet_paths = expand_stylesheet_sources(sources).collect do |source| 247 compute_public_path(source, 'stylesheets', 'css', false) 248 end 249 244 250 cache.write(join_asset_file_contents(stylesheet_paths)) 245 251 end … … 319 325 # a single or wildcarded asset host, if configured, with the correct 320 326 # request protocol. 321 def compute_public_path(source, dir, ext )327 def compute_public_path(source, dir, ext, include_host = true) 322 328 source += ".#{ext}" if File.extname(source).blank? 323 329 … … 329 335 rewrite_asset_path!(source) 330 336 331 host = compute_asset_host(source) 332 unless host.blank? or host =~ %r{^[-a-z]+://} 333 host = "#{@controller.request.protocol}#{host}" 337 if include_host 338 host = compute_asset_host(source) 339 340 unless host.blank? or host =~ %r{^[-a-z]+://} 341 host = "#{@controller.request.protocol}#{host}" 342 end 343 344 "#{host}#{source}" 345 else 346 source 334 347 end 335 336 "#{host}#{source}"337 348 end 338 349 end trunk/actionpack/test/template/asset_tag_helper_test.rb
r6164 r6187 43 43 def teardown 44 44 ActionController::Base.perform_caching = false 45 ActionController::Base.asset_host = nil 45 46 ENV["RAILS_ASSET_ID"] = nil 46 47 end … … 195 196 def test_caching_javascript_include_tag_when_caching_on 196 197 ENV["RAILS_ASSET_ID"] = "" 198 ActionController::Base.asset_host = 'http://a%d.example.com' 197 199 ActionController::Base.perform_caching = true 198 200 199 201 assert_dom_equal( 200 %(<script src=" /javascripts/all.js" type="text/javascript"></script>),202 %(<script src="http://a0.example.com/javascripts/all.js" type="text/javascript"></script>), 201 203 javascript_include_tag(:all, :cache => true) 202 204 ) … … 205 207 206 208 assert_dom_equal( 207 %(<script src=" /javascripts/money.js" type="text/javascript"></script>),209 %(<script src="http://a2.example.com/javascripts/money.js" type="text/javascript"></script>), 208 210 javascript_include_tag(:all, :cache => "money") 209 211 ) … … 236 238 def test_caching_stylesheet_link_tag_when_caching_on 237 239 ENV["RAILS_ASSET_ID"] = "" 240 ActionController::Base.asset_host = 'http://a%d.example.com' 238 241 ActionController::Base.perform_caching = true 239 242 240 243 assert_dom_equal( 241 %(<link href=" /stylesheets/all.css" media="screen" rel="Stylesheet" type="text/css" />),244 %(<link href="http://a3.example.com/stylesheets/all.css" media="screen" rel="Stylesheet" type="text/css" />), 242 245 stylesheet_link_tag(:all, :cache => true) 243 246 ) … … 246 249 247 250 assert_dom_equal( 248 %(<link href=" /stylesheets/money.css" media="screen" rel="Stylesheet" type="text/css" />),251 %(<link href="http://a3.example.com/stylesheets/money.css" media="screen" rel="Stylesheet" type="text/css" />), 249 252 stylesheet_link_tag(:all, :cache => "money") 250 253 )