summary refs log tree commit
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2011-03-18 10:20:34 -0500
committerJoshua Peek <josh@joshpeek.com>2011-03-18 10:20:34 -0500
commit1a5a44ab518c1cc97e429d717979f09c1369c88f (patch)
treee27ff85c4bfa21f450e5fc9164247c71aaf99b0b
parent397dc1ee58cec2e405b140247737b5b381556984 (diff)
parent828e2ab0396c5bbf4b5ccd76e6392a475633a81f (diff)
downloadrack-1a5a44ab518c1cc97e429d717979f09c1369c88f.tar.gz
Merge branch 'patch' of https://github.com/rkh/rack into rkh-patch
-rw-r--r--lib/rack/methodoverride.rb2
-rw-r--r--lib/rack/request.rb1
-rw-r--r--test/spec_methodoverride.rb4
-rw-r--r--test/spec_request.rb1
4 files changed, 5 insertions, 3 deletions
diff --git a/lib/rack/methodoverride.rb b/lib/rack/methodoverride.rb
index 0eed29f4..e1bca56d 100644
--- a/lib/rack/methodoverride.rb
+++ b/lib/rack/methodoverride.rb
@@ -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
diff --git a/lib/rack/request.rb b/lib/rack/request.rb
index 5ebd72ea..db3a5413 100644
--- a/lib/rack/request.rb
+++ b/lib/rack/request.rb
@@ -117,6 +117,7 @@ module Rack
     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
diff --git a/test/spec_methodoverride.rb b/test/spec_methodoverride.rb
index 853991d9..82c6cbd9 100644
--- a/test/spec_methodoverride.rb
+++ b/test/spec_methodoverride.rb
@@ -22,12 +22,12 @@ describe Rack::MethodOverride do
   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
diff --git a/test/spec_request.rb b/test/spec_request.rb
index ddaa172b..bd57af4d 100644
--- a/test/spec_request.rb
+++ b/test/spec_request.rb
@@ -16,6 +16,7 @@ describe Rack::Request do
     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 "/"