diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 87cb7b0..0cd15ac 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -77,14 +77,26 @@ module ApplicationHelper content_tag('div', @virtual_community.name, :id => 'virtual_community_identification') end + # TODO: test this helper + # TODO: remove the absolute path def link_to_cms(text, profile = nil, options = {}) profile ||= current_user.login - link_to text, "/cms/#{profile}", options + link_to text, cms_path(:profile => profile), options end def link_to_profile(text, profile = nil, options = {}) profile ||= current_user.login - link_to text, "/#{profile}", options + link_to text, profile_path(:profile => profile) , options + end + + def link_to_homepage(text, profile = nil, options = {}) + profile ||= current_user.login + link_to text, homepage_path(:profile => profile) , options + end + + def link_to_myprofile(text, url = {}, profile = nil, options = {}) + profile ||= current_user.login + link_to text, { :profile => profile }.merge(url), options end # TODO: add the actual links @@ -92,10 +104,10 @@ module ApplicationHelper def user_links links = [ ( link_to(_('My account'), { :controller => 'account' }) ), - ( link_to_profile(_('My home page')) ), + ( link_to_homepage(_('My home page')) ), ( link_to_cms(_('Manage content')) ), ( link_to (_('Manage layout')), :controller => 'edit_template' ), - ( link_to(_('My enterprises'), { :controller => 'enterprise' }) ), + ( link_to_myprofile(_('My enterprises'), { :controller => 'enterprise' }) ), ].join("\n") content_tag('span', links, :id => 'user_links') end diff --git a/app/models/profile.rb b/app/models/profile.rb index f5c8e6a..12dc5dd 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -26,6 +26,7 @@ class Profile < ActiveRecord::Base profile cms community + test ] acts_as_taggable diff --git a/config/routes.rb b/config/routes.rb index e2b286f..9fade5a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,27 +23,39 @@ ActionController::Routing::Routes.draw do |map| ## Controllers that are profile-specific (for profile admins ) ###################################################### # profile customization - "My profile" - map.connect 'myprofile', :controller => 'myprofile' - map.connect 'myprofile/:profile/:controller/:action/:id', :controller => /(edit_template|enterprise)/ + map.myprofile 'myprofile', :controller => 'myprofile' + map.myprofile 'myprofile/:profile/:controller/:action/:id', :controller => /(enterprise)/ # content administration - map.connect 'cms/:profile/:action/:id', :controller => 'cms' + map.cms 'cms/:profile/:action/:id', :controller => 'cms' ###################################################### ## Controllers that are used by environment admin ###################################################### # administrative tasks for a virtual community - map.connect 'admin', :controller => 'admin_panel' - map.connect 'admin/:controller/:action/:id', :controller => /(admin_panel|features|manage_tags)/ + map.admin 'admin', :controller => 'admin_panel' + map.admin 'admin/:controller/:action/:id', :controller => /(admin_panel|features|manage_tags|edit_template)/ ###################################################### ## Controllers that are used by system admin ###################################################### # administrative tasks for a virtual community - map.connect 'system', :controller => 'system' - map.connect 'system/:controller/:action/:id' + map.system 'system', :controller => 'system' + map.system 'system/:controller/:action/:id', :controller => // + + ###################################################### + ## Test controllers. + ## FIXME: this should not be needed + ###################################################### + map.connect 'test/:action/:id', :controller => 'test' + + ###################################################### + ## Public controllers + ###################################################### + + map.profile 'profile/:profile/:controller', :controller => 'profile' # *content viewing* # XXX this route must come last so other tasks have priority over it. - map.connect ':profile/*page', :controller => 'content_viewer', :action => 'view_page' + map.homepage ':profile/*page', :controller => 'content_viewer', :action => 'view_page' end diff --git a/test/functional/enterprise_controller_test.rb b/test/functional/enterprise_controller_test.rb index 1d2fd3b..4843ede 100644 --- a/test/functional/enterprise_controller_test.rb +++ b/test/functional/enterprise_controller_test.rb @@ -13,9 +13,19 @@ class EnterpriseControllerTest < Test::Unit::TestCase @response = ActionController::TestResponse.new end + # FIXME: this should be generic + def get(action, params = {}) + super(action, {:profile => 'ze'}.merge(params)) + end + + # FIXME: this should be generic + def post(action, params = {}) + super(action, {:profile => 'ze'}.merge(params)) + end + def test_logged_with_one_enterprise_index login_as 'ze' - get :index + get :index, :profile => 'ze' assert_response :redirect assert_redirected_to :action => 'show' diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 4011ee6..a3d3730 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -26,7 +26,7 @@ class RoutingTest < ActionController::IntegrationTest end def test_edit_template - assert_routing('/myprofile/ze/edit_template', :controller => 'edit_template', :action => 'index', :profile => 'ze') + assert_routing('/admin/edit_template', :controller => 'edit_template', :action => 'index') end # virtual community administrative controllers (admin/*) diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 0b74489..a993406 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -111,6 +111,7 @@ class ProfileTest < Test::Unit::TestCase assert_invalid_identifier 'profile' assert_invalid_identifier 'cms' assert_invalid_identifier 'community' + assert_invalid_identifier 'test' end private -- libgit2 0.21.2