Permalink
Browse files

Store original HTTP method in MethodOverride middleware

  • Loading branch information...
1 parent 76cf576 commit e20bf34ff861e8d388888f25ba5f23f696301d5f @jcrosby jcrosby committed with chneukirchen Jan 6, 2009
Showing with 11 additions and 0 deletions.
  1. +1 −0 lib/rack/methodoverride.rb
  2. +10 −0 test/spec_rack_methodoverride.rb
@@ -16,6 +16,7 @@ def call(env)
env[HTTP_METHOD_OVERRIDE_HEADER]
method = method.to_s.upcase
if HTTP_METHODS.include?(method)
+ env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"]
env["REQUEST_METHOD"] = method
end
end
@@ -47,4 +47,14 @@
req.env["REQUEST_METHOD"].should.equal "POST"
end
+
+ specify "should store the original REQUEST_METHOD prior to overriding" do
+ env = Rack::MockRequest.env_for("/",
+ :method => "POST",
+ :input => "_method=options")
+ app = Rack::MethodOverride.new(lambda { |env| Rack::Request.new(env) })
+ req = app.call(env)
+
+ req.env["rack.methodoverride.original_method"].should.equal "POST"
+ end
end

0 comments on commit e20bf34

Please sign in to comment.