Permalink
Browse files

Testcase for #3075

  • Loading branch information...
1 parent 4a631df commit c58f4f4320b063e837aec053f7291c1254814916 @kennyj committed Feb 27, 2012
Showing with 35 additions and 0 deletions.
  1. +35 −0 actionpack/test/dispatch/routing_test.rb
@@ -2434,3 +2434,38 @@ def app; Routes end
end
end
+
+class TestLambdaConstraintsPaths < ActionDispatch::IntegrationTest
+ Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|
+ app.draw do
+ scope :constraints => { :subdomain => "subdomain" } do
+ match "/" => lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ["subdomain"]] }
+ end
+
+ scope :constraints => lambda {|req| req.subdomain.present? && !%w(subdomain www).include?(req.subdomain) } do
+ match "/" => lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ["bar"]] }
+ end
+
+ root :to => lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ["default"]] }
+ end
+ end
+
+ include Routes.url_helpers
+ def app; Routes end
+
+ test 'lambda constraints paths' do
+ get "http://subdomain.foo.com"
+ assert_equal "subdomain", @response.body
+
+ get "http://bar.foo.com"
+ assert_equal "bar", @response.body
+
+ get "http://www.foo.com"
+ assert_equal "default", @response.body
+
+ get "http://foo.com"
+ assert_equal "default", @response.body
+ end
+
+end
+

0 comments on commit c58f4f4

Please sign in to comment.