From a5ae96311d93927072e0ad2d272aa5747be10d80 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 1 Aug 2008 22:25:29 +0000 Subject: [PATCH] ActionItem519: fixed routing for custom domains that are not owned by profiles --- config/routes.rb | 3 ++- test/integration/routing_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 7bb5363..4d7fbd4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,7 +17,8 @@ ActionController::Routing::Routes.draw do |map| # You can have the root of your site routed by hooking up '' hosted_domain_matcher = lambda do |env| - Domain.find_by_name(env[:host]) + domain = Domain.find_by_name(env[:host]) + domain && (domain.owner_type == 'Profile') end map.connect '*page', :controller => 'content_viewer', :action => 'view_page', :conditions => { :if => hosted_domain_matcher } diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 32e8e7e..c50a84b 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -174,4 +174,12 @@ class RoutingTest < ActionController::IntegrationTest assert_routing('/work/free-software', :controller => 'content_viewer', :action => 'view_page', :page => [ 'work', 'free-software'] ) end + def test_must_not_route_as_profile_hosted_domain_for_domains_registered_for_environments + environment = Environment.default + domain = Domain.create!(:name => 'example.com', :owner => environment) + ActionController::TestRequest.any_instance.expects(:host).returns('www.example.com') + + assert_routing('/', :controller => 'home', :action => 'index') + end + end -- libgit2 0.21.2