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

Ticket #10449: add_options_to_accepted_http_methods.patch

File add_options_to_accepted_http_methods.patch, 1.1 kB (added by holoway, 2 years ago)

Add OPTIONS to the list of allowed HTTP methods

  • test/controller/request_test.rb

    old new  
    315315 
    316316  def test_allow_method_hacking_on_post 
    317317    set_request_method_to :post 
    318     [:get, :head, :put, :post, :delete].each do |method| 
     318    [:get, :head, :options, :put, :post, :delete].each do |method| 
    319319      @request.instance_eval { @parameters = { :_method => method } ; @request_method = nil } 
    320320      assert_equal(method == :head ? :get : method, @request.method) 
    321321    end 
  • lib/action_controller/request.rb

    old new  
    44 
    55module ActionController 
    66  # HTTP methods which are accepted by default.  
    7   ACCEPTED_HTTP_METHODS = Set.new(%w( get head put post delete )) 
     7  ACCEPTED_HTTP_METHODS = Set.new(%w( get head put post delete options )) 
    88 
    99  # CgiRequest and TestRequest provide concrete implementations. 
    1010  class AbstractRequest