Updates
SVG-Edit -> 2.5final Vendored Rack -> 1.2.1
This commit is contained in:
parent
6338a3bcb2
commit
0d8f680d4f
82 changed files with 138 additions and 70 deletions
58
vendor/plugins/rack/test/spec_methodoverride.rb
vendored
Normal file
58
vendor/plugins/rack/test/spec_methodoverride.rb
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
require 'stringio'
|
||||
require 'rack/methodoverride'
|
||||
require 'rack/mock'
|
||||
|
||||
describe Rack::MethodOverride do
|
||||
should "not affect GET requests" do
|
||||
env = Rack::MockRequest.env_for("/?_method=delete", :method => "GET")
|
||||
app = Rack::MethodOverride.new(lambda{|envx| Rack::Request.new(envx) })
|
||||
req = app.call(env)
|
||||
|
||||
req.env["REQUEST_METHOD"].should.equal "GET"
|
||||
end
|
||||
|
||||
should "modify REQUEST_METHOD for POST requests when _method parameter is set" do
|
||||
env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=put")
|
||||
app = Rack::MethodOverride.new(lambda{|envx| Rack::Request.new(envx) })
|
||||
req = app.call(env)
|
||||
|
||||
req.env["REQUEST_METHOD"].should.equal "PUT"
|
||||
end
|
||||
|
||||
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"
|
||||
)
|
||||
app = Rack::MethodOverride.new(lambda{|envx| Rack::Request.new(envx) })
|
||||
req = app.call(env)
|
||||
|
||||
req.env["REQUEST_METHOD"].should.equal "PUT"
|
||||
end
|
||||
|
||||
should "not modify REQUEST_METHOD if the method is unknown" do
|
||||
env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=foo")
|
||||
app = Rack::MethodOverride.new(lambda{|envx| Rack::Request.new(envx) })
|
||||
req = app.call(env)
|
||||
|
||||
req.env["REQUEST_METHOD"].should.equal "POST"
|
||||
end
|
||||
|
||||
should "not modify REQUEST_METHOD when _method is nil" do
|
||||
env = Rack::MockRequest.env_for("/", :method => "POST", :input => "foo=bar")
|
||||
app = Rack::MethodOverride.new(lambda{|envx| Rack::Request.new(envx) })
|
||||
req = app.call(env)
|
||||
|
||||
req.env["REQUEST_METHOD"].should.equal "POST"
|
||||
end
|
||||
|
||||
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{|envx| Rack::Request.new(envx) })
|
||||
req = app.call(env)
|
||||
|
||||
req.env["rack.methodoverride.original_method"].should.equal "POST"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue