Commit de19d38056936ccdb04b8bd83840f88129c62356
1 parent
377f9153
Exists in
master
and in
29 other branches
ActionItem478: identifier with tilde not is routed
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2087 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
24 additions
and
5 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -61,7 +61,7 @@ class Profile < ActiveRecord::Base |
61 | 61 | acts_as_mappable :default_units => :kms |
62 | 62 | |
63 | 63 | # Valid identifiers must match this format. |
64 | - IDENTIFIER_FORMAT = /^[a-z][a-z0-9~.]*([_-][a-z0-9~.]+)*$/ | |
64 | + IDENTIFIER_FORMAT = /^#{Noosfero.identifier_format}$/ | |
65 | 65 | |
66 | 66 | # These names cannot be used as identifiers for Profiles |
67 | 67 | RESERVED_IDENTIFIERS = %w[ | ... | ... |
config/routes.rb
... | ... | @@ -39,7 +39,7 @@ ActionController::Routing::Routes.draw do |map| |
39 | 39 | |
40 | 40 | |
41 | 41 | # public profile information |
42 | - map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /.*/, :profile => /[a-z][a-z0-9._-]*/ | |
42 | + map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ | |
43 | 43 | |
44 | 44 | # catalog |
45 | 45 | map.catalog 'catalog/:profile', :controller => 'catalog', :action => 'index' |
... | ... | @@ -77,6 +77,6 @@ ActionController::Routing::Routes.draw do |map| |
77 | 77 | |
78 | 78 | # *content viewing* |
79 | 79 | # XXX this route must come last so other routes have priority over it. |
80 | - map.homepage ':profile/*page', :controller => 'content_viewer', :action => 'view_page', :profile => /[a-z][a-z0-9._-]*/ | |
80 | + map.homepage ':profile/*page', :controller => 'content_viewer', :action => 'view_page', :profile => /#{Noosfero.identifier_format}/ | |
81 | 81 | |
82 | 82 | end | ... | ... |
lib/noosfero.rb
1 | 1 | module Noosfero |
2 | 2 | PROJECT = 'noosfero' |
3 | - VERSION = '0.10.0' | |
3 | + VERSION = '0.10.1' | |
4 | 4 | SVN_ROOT = 'https://svn.colivre.coop.br/svn/noosfero' |
5 | 5 | |
6 | 6 | def self.pattern_for_controllers_in_directory(dir) |
... | ... | @@ -17,6 +17,10 @@ module Noosfero |
17 | 17 | end |
18 | 18 | end |
19 | 19 | |
20 | + def self.identifier_format | |
21 | + '[a-z][a-z0-9~.]*([_-][a-z0-9~.]+)*' | |
22 | + end | |
23 | + | |
20 | 24 | private |
21 | 25 | |
22 | 26 | def self.controllers_in_directory(dir) | ... | ... |
test/integration/routing_test.rb
... | ... | @@ -106,11 +106,14 @@ class RoutingTest < ActionController::IntegrationTest |
106 | 106 | assert_routing('/profile/ze_with_underscore', :controller => 'profile', :action => 'index', :profile => 'ze_with_underscore') |
107 | 107 | end |
108 | 108 | |
109 | - | |
110 | 109 | def test_profile_route_for_tags_with_dot |
111 | 110 | assert_routing('/profile/ze/tag/tag.withdot', :controller => 'profile', :profile => 'ze', :action => 'tag', :id => 'tag.withdot') |
112 | 111 | end |
113 | 112 | |
113 | + def test_profile_with_tilde_routing | |
114 | + assert_routing('/profile/ze~withtilde', :controller => 'profile', :action => 'index', :profile => 'ze~withtilde') | |
115 | + end | |
116 | + | |
114 | 117 | def test_search_routing |
115 | 118 | assert_routing('/search', :controller => 'search', :action => 'index', :category_path => []) |
116 | 119 | end |
... | ... | @@ -139,6 +142,10 @@ class RoutingTest < ActionController::IntegrationTest |
139 | 142 | assert_routing('/ze_with_underscore', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze_with_underscore', :page => []) |
140 | 143 | end |
141 | 144 | |
145 | + def test_content_view_with_tilde_routing | |
146 | + assert_routing('/ze~withtilde', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze~withtilde', :page => []) | |
147 | + end | |
148 | + | |
142 | 149 | def test_catalog_routing |
143 | 150 | assert_routing('/catalog/colivre', :controller => 'catalog', :action => 'index', :profile => 'colivre') |
144 | 151 | assert_routing('/catalog/colivre/1234', :controller => 'catalog', :action => 'show', :profile => 'colivre', :id => '1234') | ... | ... |
test/unit/noosfero_test.rb
... | ... | @@ -23,4 +23,12 @@ class NoosferoTest < Test::Unit::TestCase |
23 | 23 | assert_equal 'pt_BR', Noosfero.default_locale |
24 | 24 | end |
25 | 25 | |
26 | + should 'identifier format' do | |
27 | + assert_match /^#{Noosfero.identifier_format}$/, 'bli-bla' | |
28 | + assert_no_match /^#{Noosfero.identifier_format}$/, 'UPPER' | |
29 | + assert_no_match /^#{Noosfero.identifier_format}$/, '129812startingwithnumber' | |
30 | + assert_match /^#{Noosfero.identifier_format}$/, 'with~tilde' | |
31 | + assert_match /^#{Noosfero.identifier_format}$/, 'with.dot' | |
32 | + end | |
33 | + | |
26 | 34 | end | ... | ... |