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

Ticket #4918: fix_current_page_patch.diff

File fix_current_page_patch.diff, 1.9 kB (added by spideryoung, 9 months ago)
  • test/template/url_helper_test.rb

    old new  
    249249      link_to_unless_current("Listing", "http://www.example.com/weblog/list") 
    250250  end 
    251251 
     252  def test_current_page? 
     253    @controller.request = RequestMock.new("/weblog/show?a=b&c=d&e=f", 'http://', 'www.example.com') 
     254    assert current_page?("/weblog/show?a=b&c=d&e=f") 
     255    assert current_page?("http://www.example.com/weblog/show?a=b&c=d&e=f") 
     256    assert !current_page?("/weblog/show?a=b&e=f") 
     257    assert !current_page?("http://www.example.com/weblog/show?a=b&x=y") 
     258  end 
     259 
    252260  def test_mail_to 
    253261    assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com") 
    254262    assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson") 
  • lib/action_view/helpers/url_helper.rb

    old new  
    433433      #   current_page?(:controller => 'library', :action => 'checkout') 
    434434      #   # => false 
    435435      def current_page?(options) 
    436         url_string = CGI.escapeHTML(url_for(options)
     436        url_string = url_for(options
    437437        request = @controller.request 
     438        request_uri = CGI.escapeHTML(request.request_uri) 
    438439        if url_string =~ /^\w+:\/\// 
    439           url_string == "#{request.protocol}#{request.host_with_port}#{request.request_uri}" 
     440          url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}" 
    440441        else 
    441           url_string == request.request_uri 
     442          url_string == request_uri 
    442443        end 
    443444      end 
    444445