Commit a5ae96311d93927072e0ad2d272aa5747be10d80
1 parent
658e7bd1
Exists in
master
and in
29 other branches
ActionItem519: fixed routing for custom domains that are not owned by
profiles git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2369 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
10 additions
and
1 deletions
Show diff stats
config/routes.rb
@@ -17,7 +17,8 @@ ActionController::Routing::Routes.draw do |map| | @@ -17,7 +17,8 @@ ActionController::Routing::Routes.draw do |map| | ||
17 | 17 | ||
18 | # You can have the root of your site routed by hooking up '' | 18 | # You can have the root of your site routed by hooking up '' |
19 | hosted_domain_matcher = lambda do |env| | 19 | hosted_domain_matcher = lambda do |env| |
20 | - Domain.find_by_name(env[:host]) | 20 | + domain = Domain.find_by_name(env[:host]) |
21 | + domain && (domain.owner_type == 'Profile') | ||
21 | end | 22 | end |
22 | map.connect '*page', :controller => 'content_viewer', :action => 'view_page', :conditions => { :if => hosted_domain_matcher } | 23 | map.connect '*page', :controller => 'content_viewer', :action => 'view_page', :conditions => { :if => hosted_domain_matcher } |
23 | 24 |
test/integration/routing_test.rb
@@ -174,4 +174,12 @@ class RoutingTest < ActionController::IntegrationTest | @@ -174,4 +174,12 @@ class RoutingTest < ActionController::IntegrationTest | ||
174 | assert_routing('/work/free-software', :controller => 'content_viewer', :action => 'view_page', :page => [ 'work', 'free-software'] ) | 174 | assert_routing('/work/free-software', :controller => 'content_viewer', :action => 'view_page', :page => [ 'work', 'free-software'] ) |
175 | end | 175 | end |
176 | 176 | ||
177 | + def test_must_not_route_as_profile_hosted_domain_for_domains_registered_for_environments | ||
178 | + environment = Environment.default | ||
179 | + domain = Domain.create!(:name => 'example.com', :owner => environment) | ||
180 | + ActionController::TestRequest.any_instance.expects(:host).returns('www.example.com') | ||
181 | + | ||
182 | + assert_routing('/', :controller => 'home', :action => 'index') | ||
183 | + end | ||
184 | + | ||
177 | end | 185 | end |