Skip to content

Commit

Permalink
Testcase for rails#3075
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyj committed Feb 27, 2012
1 parent 4a631df commit c58f4f4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions actionpack/test/dispatch/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.