Commit 0f9a09855cc9c2713f8fec2e9b84b2f1649e06ac
1 parent
a30a6082
Exists in
master
and in
29 other branches
Extending profile paths to accept name or identifier
Showing
1 changed file
with
17 additions
and
12 deletions
Show diff stats
features/support/paths.rb
... | ... | @@ -37,25 +37,25 @@ module NavigationHelpers |
37 | 37 | "/myprofile/#{$2}/profile_design/edit/#{block.id}" |
38 | 38 | |
39 | 39 | when /^(.*)'s homepage$/ |
40 | - '/' + $1 | |
40 | + '/' + profile_identifier($1) | |
41 | 41 | |
42 | 42 | when /^(.*)'s blog$/ |
43 | - '/%s/blog' % Profile.find_by_name($1).identifier | |
43 | + '/%s/blog' % profile_identifier($1) | |
44 | 44 | |
45 | 45 | when /^(.*)'s (.+) creation$/ |
46 | - '/myprofile/%s/cms/new?type=%s' % [Profile.find_by_name($1).identifier,$2] | |
46 | + '/myprofile/%s/cms/new?type=%s' % [profile_identifier($1),$2] | |
47 | 47 | |
48 | 48 | when /^(.*)'s sitemap/ |
49 | - '/profile/%s/sitemap' % $1 | |
49 | + '/profile/%s/sitemap' % profile_identifier($1) | |
50 | 50 | |
51 | 51 | when /^(.*)'s profile$/ |
52 | - '/profile/' + $1 | |
52 | + '/profile/' + profile_identifier($1) | |
53 | 53 | |
54 | 54 | when /^(.*)'s join page/ |
55 | - '/profile/%s/join' % Profile.find_by_name($1).identifier | |
55 | + '/profile/%s/join' % profile_identifier($1) | |
56 | 56 | |
57 | 57 | when /^(.*)'s leave page/ |
58 | - '/profile/%s/leave' % Profile.find_by_name($1).identifier | |
58 | + '/profile/%s/leave' % profile_identifier($1) | |
59 | 59 | |
60 | 60 | when /^login page$/ |
61 | 61 | '/account/login' |
... | ... | @@ -67,7 +67,7 @@ module NavigationHelpers |
67 | 67 | '/account/signup' |
68 | 68 | |
69 | 69 | when /^(.*)'s control panel$/ |
70 | - '/myprofile/' + $1 | |
70 | + '/myprofile/' + profile_identifier($1) | |
71 | 71 | |
72 | 72 | when /the environment control panel/ |
73 | 73 | '/admin' |
... | ... | @@ -79,7 +79,7 @@ module NavigationHelpers |
79 | 79 | '/search/%s' % $1 |
80 | 80 | |
81 | 81 | when /^(.+)'s cms/ |
82 | - '/myprofile/%s/cms' % $1 | |
82 | + '/myprofile/%s/cms' % profile_identifier($1) | |
83 | 83 | |
84 | 84 | when /^"(.+)" edit page/ |
85 | 85 | article = Article.find_by_name($1) |
... | ... | @@ -89,10 +89,10 @@ module NavigationHelpers |
89 | 89 | '/myprofile/%s/profile_members' % Profile.find_by_name($1).identifier |
90 | 90 | |
91 | 91 | when /^(.+)'s new product page/ |
92 | - '/myprofile/%s/manage_products/new' % $1 | |
92 | + '/myprofile/%s/manage_products/new' % profile_identifier($1) | |
93 | 93 | |
94 | 94 | when /^(.+)'s page of product (.*)$/ |
95 | - enterprise = Profile.find_by_name($1) | |
95 | + enterprise = profile_identifier($1) | |
96 | 96 | product = enterprise.products.find_by_name($2) |
97 | 97 | '/myprofile/%s/manage_products/show/%s' % [enterprise.identifier, product.id] |
98 | 98 | |
... | ... | @@ -109,7 +109,7 @@ module NavigationHelpers |
109 | 109 | '/account/user_data' |
110 | 110 | |
111 | 111 | when /^(.+)'s members page/ |
112 | - '/profile/%s/members' % Profile.find_by_name($1).identifier | |
112 | + '/profile/%s/members' % profile_identifier($1) | |
113 | 113 | |
114 | 114 | else |
115 | 115 | begin |
... | ... | @@ -122,6 +122,11 @@ module NavigationHelpers |
122 | 122 | end |
123 | 123 | end |
124 | 124 | end |
125 | + | |
126 | + def profile_identifier(field) | |
127 | + profile = Profile.find_by_name(field) || Profile.find_by_identifier(field) | |
128 | + profile.identifier | |
129 | + end | |
125 | 130 | end |
126 | 131 | |
127 | 132 | World(NavigationHelpers) | ... | ... |