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

Changeset 7572

Show
Ignore:
Timestamp:
09/22/07 19:20:06 (1 year ago)
Author:
nzkoz
Message:

Disable the routing optimisation code when dealing with foo_url helpers. Add test to actionmailer to expose the problem they introduced. References #9450 [Koz]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb

    r6180 r7572  
    11Hello there,  
    22 
    3 Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %> 
     3Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %> <%= welcome_url %> 
  • trunk/actionmailer/test/url_test.rb

    r5081 r7572  
    22 
    33class TestMailer < ActionMailer::Base 
     4   
     5  default_url_options[:host] = 'www.basecamphq.com' 
     6   
    47  def signed_up_with_url(recipient) 
    58    @recipients   = recipient 
     
    4851    ActionController::Routing::Routes.draw do |map|  
    4952      map.connect ':controller/:action/:id'  
     53      map.welcome 'welcome', :controller=>"foo", :action=>"bar" 
    5054    end 
    5155 
     
    5357    expected.to      = @recipient 
    5458    expected.subject = "[Signed up] Welcome #{@recipient}" 
    55     expected.body    = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting
     59    expected.body    = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome
    5660    expected.from    = "system@loudthinking.com" 
    5761    expected.date    = Time.local(2004, 12, 12) 
  • trunk/actionpack/lib/action_controller/routing_optimisation.rb

    r7501 r7572  
    4242        end 
    4343 
     44        # Temporarily disabled :url optimisation pending proper solution to  
     45        # Issues around request.host etc. 
    4446        def applicable? 
    45           true 
     47          kind != :url 
    4648        end 
    4749      end 
     
    7779          # 'divider segment' for '/' but we have assertions to ensure that 
    7880          # we don't include the trailing slashes, so skip them. 
    79           ((route.segments.size == 1 && kind == :path) ? route.segments : route.segments[0..-2]).each do |segment| 
     81          (route.segments.size == 1 ? route.segments : route.segments[0..-2]).each do |segment| 
    8082            if segment.is_a?(DynamicSegment) 
    8183              elements << segment.interpolation_chunk("args[#{idx}].to_param") 
     
    106108        # can't use this optimisation on routes without any segments 
    107109        def applicable? 
    108           route.segment_keys.size > 0  
     110          super && route.segment_keys.size > 0  
    109111        end 
    110112      end 
  • trunk/actionpack/test/controller/routing_test.rb

    r7501 r7572  
    170170    rs.add_named_route :home, '', :controller => 'content', :action => 'list'  
    171171    x = setup_for_named_route 
    172     assert_equal("http://named.route.test", 
     172    assert_equal("http://named.route.test/", 
    173173                 x.send(:home_url)) 
    174174  end 
     
    190190 
    191191  def test_named_route_with_nested_controller 
    192     rs.add_named_route :users, '/admin/user', :controller => '/admin/user', :action => 'index' 
     192    rs.add_named_route :users, 'admin/user', :controller => 'admin/user', :action => 'index' 
    193193    x = setup_for_named_route 
    194194    assert_equal("http://named.route.test/admin/user", 
     
    202202      x = setup_for_named_route 
    203203      x.expects(:url_for).never 
    204       x.send(:users_url) 
     204      # x.send(:users_url) 
    205205      x.send(:users_path) 
    206       x.send(:user_url, 2, :foo=>"bar") 
     206      # x.send(:user_url, 2, :foo=>"bar") 
    207207      x.send(:user_path, 3, :bar=>"foo") 
    208208    end 
     
    226226    end                      
    227227    x = setup_for_named_route        
    228     assert_equal("http://named.route.test", x.send(:root_url)) 
     228    assert_equal("http://named.route.test/", x.send(:root_url)) 
    229229    assert_equal("/", x.send(:root_path)) 
    230230  end 
     
    486486     
    487487    x = setup_for_named_route 
    488     assert_equal("http://named.route.test", 
     488    assert_equal("http://named.route.test/", 
    489489                 x.send(:home_url)) 
    490490  end