Commit 18be95f3409d7ac0240ea2d833a2ac9b9a64da9f
1 parent
5d4345c4
Exists in
master
and in
29 other branches
r216@sede: terceiro | 2007-07-28 10:55:21 -0300
ActionItem7: integrating comatose_admin in the application. Awesome! :) git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@220 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
46 additions
and
14 deletions
Show diff stats
app/views/content_viewer/view_page.rhtml
config/environment.rb
| ... | ... | @@ -54,3 +54,13 @@ end |
| 54 | 54 | |
| 55 | 55 | require 'gettext/rails' |
| 56 | 56 | Tag.hierarchical = true |
| 57 | + | |
| 58 | +Comatose.configure do |config| | |
| 59 | + config.admin_get_root_page do | |
| 60 | + Comatose::Page.find_by_path(request.parameters[:profile]) | |
| 61 | + end | |
| 62 | + config.admin_authorization do |config| | |
| 63 | + Profile.exists?(:identifier => request.parameters[:profile]) | |
| 64 | + # FIXME: also check permissions | |
| 65 | + end | |
| 66 | +end | ... | ... |
config/routes.rb
| ... | ... | @@ -13,22 +13,25 @@ ActionController::Routing::Routes.draw do |map| |
| 13 | 13 | # -- just remember to delete public/index.html. |
| 14 | 14 | map.connect '', :controller => "home" |
| 15 | 15 | |
| 16 | + # documentation browser | |
| 17 | + map.connect 'doc', :controller => 'doc' | |
| 18 | + | |
| 16 | 19 | # user account controller |
| 17 | 20 | map.connect 'account/:action', :controller => 'account' |
| 18 | - map.connect 'doc', :controller => 'doc' | |
| 21 | + | |
| 22 | + # TODO: profile customization for profiles | |
| 23 | + # map.connect 'customize/:profile/:controller/:action/:id' | |
| 24 | + | |
| 25 | + # content administration | |
| 26 | + map.comatose_admin 'cms/:profile' | |
| 19 | 27 | |
| 20 | 28 | # administrative tasks for a virtual community |
| 21 | 29 | map.connect 'admin/:controller/:action/:id' |
| 22 | 30 | |
| 23 | - # profile customization for profiles | |
| 24 | - map.connect 'customize/:profile/:controller/:action/:id' | |
| 25 | - | |
| 26 | - # content viewwing: | |
| 31 | + # content viewing: | |
| 27 | 32 | map.connect ':profile/*page', :controller => 'content_viewer', :action => 'view_page' |
| 28 | 33 | |
| 29 | - # Install the default route as the lowest priority. | |
| 30 | - map.connect ':controller/:action/:id' | |
| 31 | - | |
| 32 | - # TODO: comatose here | |
| 34 | + # no default route | |
| 35 | + # map.connect ':controller/:action/:id' | |
| 33 | 36 | |
| 34 | 37 | end | ... | ... |
test/integration/routing_test.rb
| ... | ... | @@ -2,19 +2,36 @@ require "#{File.dirname(__FILE__)}/../test_helper" |
| 2 | 2 | |
| 3 | 3 | class RoutingTest < ActionController::IntegrationTest |
| 4 | 4 | |
| 5 | - def test_features_controller | |
| 6 | - assert_routing('/admin/features', :controller => 'features', :action => 'index') | |
| 5 | + def test_homepage | |
| 6 | + assert_routing('/', :controller => 'home', :action => 'index') | |
| 7 | + end | |
| 8 | + | |
| 9 | + def test_doc_controller | |
| 10 | + #FIXME: assert_routing cannot find controllers in plugins' | |
| 11 | + flunk 'FIXME: assert_routing cannot find controllers in plugins' | |
| 12 | + assert_routing('/doc', :controller => 'doc', :action => 'index') | |
| 7 | 13 | end |
| 8 | 14 | |
| 9 | 15 | def test_account_controller |
| 10 | 16 | assert_routing('/account', :controller => 'account', :action => 'index') |
| 11 | 17 | end |
| 12 | 18 | |
| 13 | - def test_content_viewer_controller_for_profile_root | |
| 14 | - assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => []) | |
| 19 | + def test_comatose_admin | |
| 20 | + #FIXME: assert_routing cannot find controllers in plugins' | |
| 21 | + flunk 'FIXME: assert_routing cannot find controllers in plugins' | |
| 22 | + assert_routing('/cms/ze', :controller => 'comatose_admin') | |
| 23 | + end | |
| 24 | + | |
| 25 | + def test_features_controller | |
| 26 | + assert_routing('/admin/features', :controller => 'features', :action => 'index') | |
| 15 | 27 | end |
| 16 | 28 | |
| 17 | - def test_content_viewer_controller_for_page_inside_profile | |
| 29 | + def test_content_viewer | |
| 30 | + | |
| 31 | + # profile root: | |
| 32 | + assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => []) | |
| 33 | + | |
| 34 | + # some non-root page | |
| 18 | 35 | assert_routing('/ze/work/2007', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => ['work', "2007"]) |
| 19 | 36 | end |
| 20 | 37 | ... | ... |