diff options
author | wycats <wycats@gmail.com> | 2010-04-03 20:23:23 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-04-03 20:24:30 -0700 |
commit | ab8bf9e152ad75c8b358c85e4c95cfde578de127 (patch) | |
tree | 1e5887a4c0bdbf0750c359dc8d1c6d2d5585a5bf /actionpack/test/dispatch/routing_test.rb | |
parent | 512b4bccfbe222bd7f94adf6f9af07c2e856767d (diff) | |
download | rails-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/routing_test.rb')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 19538cb88b..bb7c322790 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -187,6 +187,63 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end + class TestAltApp < ActionController::IntegrationTest + class AltRequest + def initialize(env) + @env = env + end + + def path_info + "/" + end + + def request_method + "GET" + end + + def x_header + @env["HTTP_X_HEADER"] || "" + end + end + + class XHeader + def call(env) + [200, {"Content-Type" => "text/html"}, ["XHeader"]] + end + end + + class AltApp + def call(env) + [200, {"Content-Type" => "text/html"}, ["Alternative App"]] + end + end + + AltRoutes = ActionDispatch::Routing::RouteSet.new(AltRequest) + AltRoutes.draw do + get "/" => XHeader.new, :constraints => {:x_header => /HEADER/} + get "/" => AltApp.new + end + + def app + AltRoutes + end + + def test_alt_request_without_header + get "/" + assert_equal "Alternative App", @response.body + end + + def test_alt_request_with_matched_header + get "/", {}, "HTTP_X_HEADER" => "HEADER" + assert_equal "XHeader", @response.body + end + + def test_alt_request_with_unmatched_header + get "/", {}, "HTTP_X_HEADER" => "NON_MATCH" + assert_equal "Alternative App", @response.body + end + end + def app Routes end |