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

Ticket #7124: alias_xhr_to_xml_http_request.diff

File alias_xhr_to_xml_http_request.diff, 1.5 kB (added by nik.wakelin, 2 years ago)
  • actionpack/test/controller/integration_test.rb

    old new  
    141141    @session.expects(:post).with(path,params,headers_after_xhr) 
    142142    @session.xml_http_request(path,params,headers) 
    143143  end 
     144 
     145  def test_xhr_is_aliased_to_xml_http_request 
     146    path = "/index"; params = "blah"; headers = {:location => 'blah'} 
     147    headers_after_xhr = headers.merge( 
     148      "X-Requested-With" => "XMLHttpRequest", 
     149      "Accept"           => "text/javascript, text/html, application/xml, text/xml, */*" 
     150    ) 
     151    @session.expects(:post).with(path,params,headers_after_xhr) 
     152    @session.xhr(path,params,headers) 
     153  end  
     154 
     155     
    144156end 
    145157 
    146158# TODO 
  • actionpack/lib/action_controller/integration.rb

    old new  
    186186 
    187187        post(path, parameters, headers) 
    188188      end 
     189       
     190      alias xhr :xml_http_request 
    189191 
    190192      # Returns the URL for the given options, according to the rules specified 
    191193      # in the application's routes. 
     
    500502        end 
    501503      end 
    502504    end 
     505     
     506    alias xhr :xml_http_request 
    503507 
    504508    # Open a new session instance. If a block is given, the new session is 
    505509    # yielded to the block before being returned.