Commit 614c64ab4ea059f713185cc981af353da918057b
1 parent
9c9f424b
Exists in
master
and in
29 other branches
ActionItem8: changing routing scheme
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@422 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
56 additions
and
29 deletions
Show diff stats
app/models/profile.rb
config/routes.rb
... | ... | @@ -19,22 +19,31 @@ ActionController::Routing::Routes.draw do |map| |
19 | 19 | # user account controller |
20 | 20 | map.connect 'account/:action', :controller => 'account' |
21 | 21 | |
22 | - # profile customization | |
23 | - map.connect 'customize/:profile/edit_template/:action/:id', :controller => 'edit_template' | |
24 | - | |
25 | - # content administration | |
22 | + ###################################################### | |
23 | + ## Controllers that are profile-specific (for profile admins ) | |
24 | + ###################################################### | |
25 | + # profile customization - "My profile" | |
26 | + map.connect 'myprofile', :controller => 'myprofile' | |
27 | + map.connect 'myprofile/:profile/:controller/:action/:id', :controller => /(edit_template|enterprise)/ | |
28 | + # content administration | |
26 | 29 | map.connect 'cms/:profile/:action/:id', :controller => 'cms' |
27 | 30 | |
31 | + ###################################################### | |
32 | + ## Controllers that are used by environment admin | |
33 | + ###################################################### | |
28 | 34 | # administrative tasks for a virtual community |
29 | - map.connect 'admin', :controller => 'admin_panel', :action => 'index' | |
30 | - map.connect 'admin/:controller/:action/:id' | |
35 | + map.connect 'admin', :controller => 'admin_panel' | |
36 | + map.connect 'admin/:controller/:action/:id', :controller => /(admin_panel|features|manage_tags)/ | |
31 | 37 | |
38 | + ###################################################### | |
39 | + ## Controllers that are used by system admin | |
40 | + ###################################################### | |
41 | + # administrative tasks for a virtual community | |
42 | + map.connect 'system', :controller => 'system' | |
43 | + map.connect 'system/:controller/:action/:id' | |
32 | 44 | |
33 | 45 | # *content viewing* |
34 | 46 | # XXX this route must come last so other tasks have priority over it. |
35 | 47 | map.connect ':profile/*page', :controller => 'content_viewer', :action => 'view_page' |
36 | 48 | |
37 | - # no default route | |
38 | - # map.connect ':controller/:action/:id' | |
39 | - | |
40 | 49 | end | ... | ... |
test/integration/activate_enterprise_test.rb
... | ... | @@ -6,14 +6,14 @@ class ActivateEnterpriseTest < ActionController::IntegrationTest |
6 | 6 | def test_activate_approved_enterprise |
7 | 7 | login('ze', 'test') |
8 | 8 | |
9 | - get '/admin/enterprise' | |
9 | + get '/myprofile/ze/enterprise' | |
10 | 10 | assert_response :redirect |
11 | 11 | |
12 | 12 | follow_redirect! |
13 | 13 | assert_response :success |
14 | - assert_tag :tag => 'a', :attributes => {:href => '/admin/enterprise/activate/5'} | |
14 | + assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/enterprise/activate/5'} | |
15 | 15 | |
16 | - post '/admin/enterprise/activate/5' | |
16 | + post '/myprofile/ze/enterprise/activate/5' | |
17 | 17 | assert_response :redirect |
18 | 18 | |
19 | 19 | follow_redirect! | ... | ... |
test/integration/edit_enterprise_test.rb
... | ... | @@ -3,30 +3,30 @@ require "#{File.dirname(__FILE__)}/../test_helper" |
3 | 3 | class EditEnterpriseTest < ActionController::IntegrationTest |
4 | 4 | all_fixtures |
5 | 5 | def test_edit_an_enterprise |
6 | - get '/admin/enterprise' | |
6 | + get '/myprofile/ze/enterprise' | |
7 | 7 | assert_response :redirect |
8 | 8 | |
9 | 9 | login('ze', 'test') |
10 | 10 | |
11 | - get '/admin/enterprise' | |
11 | + get '/myprofile/ze/enterprise' | |
12 | 12 | assert_response :redirect |
13 | 13 | |
14 | 14 | follow_redirect! |
15 | 15 | assert_response :success |
16 | - assert_tag :tag => 'a', :attributes => {:href => '/admin/enterprise/edit/5'} | |
16 | + assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/enterprise/edit/5'} | |
17 | 17 | |
18 | - get '/admin/enterprise/edit/5' | |
18 | + get '/myprofile/ze/enterprise/edit/5' | |
19 | 19 | assert_response :success |
20 | 20 | assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} |
21 | 21 | |
22 | - post '/admin/enterprise/update/5', :enterprise => {'name' => 'new_name' } | |
22 | + post '/myprofile/ze/enterprise/update/5', :enterprise => {'name' => 'new_name' } | |
23 | 23 | assert_response :redirect |
24 | 24 | |
25 | 25 | follow_redirect! |
26 | 26 | assert_response :redirect |
27 | 27 | |
28 | 28 | follow_redirect! |
29 | - assert_equal '/admin/enterprise/show/5', path | |
29 | + assert_equal '/myprofile/ze/enterprise/show/5', path | |
30 | 30 | |
31 | 31 | end |
32 | 32 | end | ... | ... |
test/integration/register_enterprise_test.rb
... | ... | @@ -4,24 +4,24 @@ class RegisterEnterpriseTest < ActionController::IntegrationTest |
4 | 4 | all_fixtures |
5 | 5 | |
6 | 6 | def test_register_new_enterprise |
7 | - get '/admin/enterprise' | |
7 | + get '/myprofile/ze/enterprise' | |
8 | 8 | assert_response :redirect |
9 | 9 | |
10 | 10 | login('ze','test') |
11 | 11 | |
12 | - get '/admin/enterprise' | |
12 | + get '/myprofile/ze/enterprise' | |
13 | 13 | assert_response :redirect |
14 | 14 | |
15 | 15 | follow_redirect! |
16 | 16 | assert_response :success |
17 | - assert_tag :tag => 'a', :attributes => {:href => '/admin/enterprise/register_form'} | |
17 | + assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/enterprise/register_form'} | |
18 | 18 | |
19 | - get '/admin/enterprise/register_form' | |
19 | + get '/myprofile/ze/enterprise/register_form' | |
20 | 20 | assert_response :success |
21 | 21 | assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} |
22 | 22 | assert_tag :tag => 'input', :attributes => {:name => 'enterprise[identifier]'} |
23 | 23 | |
24 | - post '/admin/enterprise/register', :enterprise => {'name' => 'new_enterprise', 'identifier' => 'enterprise_new'} | |
24 | + post '/myprofile/ze/enterprise/register', :enterprise => {'name' => 'new_enterprise', 'identifier' => 'enterprise_new'} | |
25 | 25 | assert_response :redirect |
26 | 26 | |
27 | 27 | follow_redirect! | ... | ... |
test/integration/routing_test.rb
... | ... | @@ -26,7 +26,7 @@ class RoutingTest < ActionController::IntegrationTest |
26 | 26 | end |
27 | 27 | |
28 | 28 | def test_edit_template |
29 | - assert_routing('/customize/ze/edit_template', :controller => 'edit_template', :action => 'index', :profile => 'ze') | |
29 | + assert_routing('/myprofile/ze/edit_template', :controller => 'edit_template', :action => 'index', :profile => 'ze') | |
30 | 30 | end |
31 | 31 | |
32 | 32 | # virtual community administrative controllers (admin/*) | ... | ... |
test/integration/search_enterprise_test.rb
... | ... | @@ -5,14 +5,14 @@ class SearchEnterpriseTest < ActionController::IntegrationTest |
5 | 5 | |
6 | 6 | def test_search_by_name_or_tag |
7 | 7 | login('ze', 'test') |
8 | - get '/admin/enterprise' | |
8 | + get '/myprofile/ze/enterprise' | |
9 | 9 | assert_response :redirect |
10 | 10 | |
11 | 11 | follow_redirect! |
12 | 12 | assert_response :success |
13 | 13 | assert_tag :tag => 'input', :attributes => {'name', 'query'} |
14 | 14 | |
15 | - get '/admin/enterprise/search', :query => 'bla' | |
15 | + get '/myprofile/ze/enterprise/search', :query => 'bla' | |
16 | 16 | assert_response :success |
17 | 17 | end |
18 | 18 | end | ... | ... |
test/unit/person_test.rb
... | ... | @@ -13,7 +13,7 @@ class PersonTest < Test::Unit::TestCase |
13 | 13 | end |
14 | 14 | |
15 | 15 | def test_can_associate_to_a_profile |
16 | - pr = Profile.new(:identifier => 'profile', :name => 'profile') | |
16 | + pr = Profile.new(:identifier => 'mytestprofile', :name => 'My test profile') | |
17 | 17 | assert pr.save |
18 | 18 | pe = User.create(:login => 'person', :email => 'person@test.net', :password => 'dhoe', :password_confirmation => 'dhoe').person |
19 | 19 | assert pe.save | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -104,4 +104,21 @@ class ProfileTest < Test::Unit::TestCase |
104 | 104 | assert_nil Profile.new.info |
105 | 105 | end |
106 | 106 | |
107 | + def test_should_avoid_reserved_identifiers | |
108 | + assert_invalid_identifier 'admin' | |
109 | + assert_invalid_identifier 'system' | |
110 | + assert_invalid_identifier 'myprofile' | |
111 | + assert_invalid_identifier 'profile' | |
112 | + assert_invalid_identifier 'cms' | |
113 | + assert_invalid_identifier 'community' | |
114 | + end | |
115 | + | |
116 | + private | |
117 | + | |
118 | + def assert_invalid_identifier(id) | |
119 | + profile = Profile.new(:identifier => id) | |
120 | + assert !profile.valid? | |
121 | + assert profile.errors.invalid?(:identifier) | |
122 | + end | |
123 | + | |
107 | 124 | end | ... | ... |