aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request_test.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-04-03 20:23:23 -0700
committerwycats <wycats@gmail.com>2010-04-03 20:24:30 -0700
commitab8bf9e152ad75c8b358c85e4c95cfde578de127 (patch)
tree1e5887a4c0bdbf0750c359dc8d1c6d2d5585a5bf /actionpack/test/dispatch/request_test.rb
parent512b4bccfbe222bd7f94adf6f9af07c2e856767d (diff)
downloadrails-ab8bf9e152ad75c8b358c85e4c95cfde578de127.tar.gz
rails-ab8bf9e152ad75c8b358c85e4c95cfde578de127.tar.bz2
rails-ab8bf9e152ad75c8b358c85e4c95cfde578de127.zip
* Change the object used in routing constraints to be an instance of
ActionDispatch::Request rather than Rack::Request. * Changed ActionDispatch::Request#method to return a String, to be compatible with the Rack::Request superclass. * Changed ActionDispatch::Request#method to return the original method in the case of methodoverride and #request_method not to, to be compatible with Rack::Request
Diffstat (limited to 'actionpack/test/dispatch/request_test.rb')
-rw-r--r--actionpack/test/dispatch/request_test.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index 9093e1ed65..e5ee412021 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -223,10 +223,17 @@ class RequestTest < ActiveSupport::TestCase
assert request.ssl?
end
- test "symbolized request methods" do
+ test "String request methods" do
[:get, :post, :put, :delete].each do |method|
request = stub_request 'REQUEST_METHOD' => method.to_s.upcase
- assert_equal method, request.method
+ assert_equal method.to_s.upcase, request.method
+ end
+ end
+
+ test "Symbol forms of request methods via method_symbol" do
+ [:get, :post, :put, :delete].each do |method|
+ request = stub_request 'REQUEST_METHOD' => method.to_s.upcase
+ assert_equal method, request.method_symbol
end
end
@@ -238,9 +245,9 @@ class RequestTest < ActiveSupport::TestCase
end
test "allow method hacking on post" do
- [:get, :options, :put, :post, :delete].each do |method|
+ %w(GET OPTIONS PUT POST DELETE).each do |method|
request = stub_request "REQUEST_METHOD" => method.to_s.upcase
- assert_equal(method == :head ? :get : method, request.method)
+ assert_equal(method == "HEAD" ? "GET" : method, request.method)
end
end
@@ -255,13 +262,14 @@ class RequestTest < ActiveSupport::TestCase
[:get, :put, :delete].each do |method|
request = stub_request 'REQUEST_METHOD' => method.to_s.upcase,
'action_dispatch.request.request_parameters' => { :_method => 'put' }
- assert_equal method, request.method
+ assert_equal method.to_s.upcase, request.method
end
end
test "head masquerading as get" do
request = stub_request 'REQUEST_METHOD' => 'GET', "rack.methodoverride.original_method" => "HEAD"
- assert_equal :get, request.method
+ assert_equal "HEAD", request.method
+ assert_equal "GET", request.request_method
assert request.get?
assert request.head?
end