Skip to content

Commit

Permalink
Merge branch 'patch' of https://github.com/rkh/rack into rkh-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 18, 2011
2 parents 397dc1e + 828e2ab commit 1a5a44a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rack/methodoverride.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Rack
class MethodOverride
HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS)
HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS PATCH)

METHOD_OVERRIDE_PARAM_KEY = "_method".freeze
HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze
Expand Down
1 change: 1 addition & 0 deletions lib/rack/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def delete?; request_method == "DELETE" end
def get?; request_method == "GET" end
def head?; request_method == "HEAD" end
def options?; request_method == "OPTIONS" end
def patch?; request_method == "PATCH" end
def post?; request_method == "POST" end
def put?; request_method == "PUT" end
def trace?; request_method == "TRACE" end
Expand Down
4 changes: 2 additions & 2 deletions test/spec_methodoverride.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
should "modify REQUEST_METHOD for POST requests when X-HTTP-Method-Override is set" do
env = Rack::MockRequest.env_for("/",
:method => "POST",
"HTTP_X_HTTP_METHOD_OVERRIDE" => "PUT"
"HTTP_X_HTTP_METHOD_OVERRIDE" => "PATCH"
)
app = Rack::MethodOverride.new(lambda{|envx| Rack::Request.new(envx) })
req = app.call(env)

req.env["REQUEST_METHOD"].should.equal "PUT"
req.env["REQUEST_METHOD"].should.equal "PATCH"
end

should "not modify REQUEST_METHOD if the method is unknown" do
Expand Down
1 change: 1 addition & 0 deletions test/spec_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
req.should.not.be.put
req.should.not.be.delete
req.should.not.be.head
req.should.not.be.patch

req.script_name.should.equal ""
req.path_info.should.equal "/"
Expand Down

0 comments on commit 1a5a44a

Please sign in to comment.