Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8834

Show
Ignore:
Timestamp:
02/10/08 01:07:24 (5 months ago)
Author:
nzkoz
Message:

2-0-stable: Don't repeatedly add relative_url_root to asset sources. References #10767 [tomtoday, Koz]

Merging [8740]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2-0-stable/actionpack/lib/action_view/helpers/asset_tag_helper.rb

    r8642 r8834  
    436436                source = "/#{dir}/#{source}" unless source[0] == ?/ 
    437437                if has_request 
    438                   source = "#{@controller.request.relative_url_root}#{source}" 
     438                  unless source =~ %r{^#{@controller.request.relative_url_root}/} 
     439                    source = "#{@controller.request.relative_url_root}#{source}" 
     440                  end 
    439441                end 
    440                 rewrite_asset_path!(source) 
     442                source = rewrite_asset_path(source) 
    441443 
    442444                if include_host 
     
    485487        end 
    486488 
    487         # Break out the asset path rewrite so you wish to put the asset id 
     489        # Break out the asset path rewrite in case plugins wish to put the asset id 
    488490        # someplace other than the query string. 
    489         def rewrite_asset_path!(source) 
     491        def rewrite_asset_path(source) 
    490492          asset_id = rails_asset_id(source) 
    491           source << "?#{asset_id}" if !asset_id.blank? 
     493          if asset_id.blank? 
     494            source 
     495          else 
     496            source + "?#{asset_id}" 
     497          end 
    492498        end 
    493499 
  • branches/2-0-stable/actionpack/test/template/asset_tag_helper_test.rb

    r8470 r8834  
    393393    assert_dom_equal(%(/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style")) 
    394394    assert_dom_equal(%(/collaboration/hieraki/images/xml.png), image_path("xml.png")) 
     395    assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse.png'" src="/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) 
     396    assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse2.png'" src="/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png"))) 
    395397  end 
    396398   
     
    405407    assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style")) 
    406408    assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png")) 
     409    assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png")) 
     410    assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse2.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png"))) 
    407411  ensure 
    408412    ActionController::Base.asset_host = ""