From 4a74f898ec3b109e439548fa19ac33c00b872d31 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 3 Apr 2009 10:50:23 -0300 Subject: [PATCH] ActionItem959: making it work for communities with their own domain --- app/views/shared/join_community_popup.rhtml | 2 +- config/routes.rb | 1 + test/integration/routing_test.rb | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/shared/join_community_popup.rhtml b/app/views/shared/join_community_popup.rhtml index 34952ae..56540d8 100644 --- a/app/views/shared/join_community_popup.rhtml +++ b/app/views/shared/join_community_popup.rhtml @@ -7,7 +7,7 @@ <% else %> <%= button(:ok, _('Yes'), :controller => 'profile', :action => 'join', :profile => profile.identifier) %> <% end %> - <%= button_to_remote(:cancel, _('Not now'), :url => {:controller => 'profile', :action => 'refuse_for_now', :profile => profile.identifier}, :loaded => '$("join-community-popup").hide()') %> + <%= button_to_remote(:cancel, _('Not now'), :url => profile.url.merge({:controller => 'profile', :action => 'refuse_for_now', :profile => profile.identifier}), :loaded => '$("join-community-popup").hide()') %> <%= button(:cancel, _('No and don\'t ask again'), :controller => 'profile', :action => 'refuse_join', :profile => profile.identifier) if logged_in? %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index defdc3d..ce1ab7b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,7 @@ ActionController::Routing::Routes.draw do |map| domain = Domain.find_by_name(env[:host]) domain && (domain.owner_type == 'Profile') end + map.connect 'profile/:profile/:action/:id', :controller => 'profile', :id => /.*/, :profile => /#{Noosfero.identifier_format}/, :conditions => { :if => hosted_domain_matcher } map.connect '*page', :controller => 'content_viewer', :action => 'view_page', :conditions => { :if => hosted_domain_matcher } map.connect 'test/:controller/:action/:id' , :controller => /.*test.*/ diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index cf02f10..035639c 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -174,6 +174,15 @@ class RoutingTest < ActionController::IntegrationTest assert_routing('/work/free-software', :controller => 'content_viewer', :action => 'view_page', :page => [ 'work', 'free-software'] ) end + def test_profile_under_hosted_domain + community = Community.create!(:identifier => 'testcomm', :name => "test community") + domain = Domain.create!(:name => 'example.com', :owner => community) + + ActionController::TestRequest.any_instance.expects(:host).returns('www.example.com') + + assert_routing('/profile/testcomm/refuse_for_now', :controller => 'profile', :action => 'refuse_for_now', :profile => 'testcomm') + 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) -- libgit2 0.21.2