Commit 0f9a09855cc9c2713f8fec2e9b84b2f1649e06ac
1 parent
a30a6082
Exists in
staging
and in
42 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,25 +37,25 @@ module NavigationHelpers | ||
37 | "/myprofile/#{$2}/profile_design/edit/#{block.id}" | 37 | "/myprofile/#{$2}/profile_design/edit/#{block.id}" |
38 | 38 | ||
39 | when /^(.*)'s homepage$/ | 39 | when /^(.*)'s homepage$/ |
40 | - '/' + $1 | 40 | + '/' + profile_identifier($1) |
41 | 41 | ||
42 | when /^(.*)'s blog$/ | 42 | when /^(.*)'s blog$/ |
43 | - '/%s/blog' % Profile.find_by_name($1).identifier | 43 | + '/%s/blog' % profile_identifier($1) |
44 | 44 | ||
45 | when /^(.*)'s (.+) creation$/ | 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 | when /^(.*)'s sitemap/ | 48 | when /^(.*)'s sitemap/ |
49 | - '/profile/%s/sitemap' % $1 | 49 | + '/profile/%s/sitemap' % profile_identifier($1) |
50 | 50 | ||
51 | when /^(.*)'s profile$/ | 51 | when /^(.*)'s profile$/ |
52 | - '/profile/' + $1 | 52 | + '/profile/' + profile_identifier($1) |
53 | 53 | ||
54 | when /^(.*)'s join page/ | 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 | when /^(.*)'s leave page/ | 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 | when /^login page$/ | 60 | when /^login page$/ |
61 | '/account/login' | 61 | '/account/login' |
@@ -67,7 +67,7 @@ module NavigationHelpers | @@ -67,7 +67,7 @@ module NavigationHelpers | ||
67 | '/account/signup' | 67 | '/account/signup' |
68 | 68 | ||
69 | when /^(.*)'s control panel$/ | 69 | when /^(.*)'s control panel$/ |
70 | - '/myprofile/' + $1 | 70 | + '/myprofile/' + profile_identifier($1) |
71 | 71 | ||
72 | when /the environment control panel/ | 72 | when /the environment control panel/ |
73 | '/admin' | 73 | '/admin' |
@@ -79,7 +79,7 @@ module NavigationHelpers | @@ -79,7 +79,7 @@ module NavigationHelpers | ||
79 | '/search/%s' % $1 | 79 | '/search/%s' % $1 |
80 | 80 | ||
81 | when /^(.+)'s cms/ | 81 | when /^(.+)'s cms/ |
82 | - '/myprofile/%s/cms' % $1 | 82 | + '/myprofile/%s/cms' % profile_identifier($1) |
83 | 83 | ||
84 | when /^"(.+)" edit page/ | 84 | when /^"(.+)" edit page/ |
85 | article = Article.find_by_name($1) | 85 | article = Article.find_by_name($1) |
@@ -89,10 +89,10 @@ module NavigationHelpers | @@ -89,10 +89,10 @@ module NavigationHelpers | ||
89 | '/myprofile/%s/profile_members' % Profile.find_by_name($1).identifier | 89 | '/myprofile/%s/profile_members' % Profile.find_by_name($1).identifier |
90 | 90 | ||
91 | when /^(.+)'s new product page/ | 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 | when /^(.+)'s page of product (.*)$/ | 94 | when /^(.+)'s page of product (.*)$/ |
95 | - enterprise = Profile.find_by_name($1) | 95 | + enterprise = profile_identifier($1) |
96 | product = enterprise.products.find_by_name($2) | 96 | product = enterprise.products.find_by_name($2) |
97 | '/myprofile/%s/manage_products/show/%s' % [enterprise.identifier, product.id] | 97 | '/myprofile/%s/manage_products/show/%s' % [enterprise.identifier, product.id] |
98 | 98 | ||
@@ -109,7 +109,7 @@ module NavigationHelpers | @@ -109,7 +109,7 @@ module NavigationHelpers | ||
109 | '/account/user_data' | 109 | '/account/user_data' |
110 | 110 | ||
111 | when /^(.+)'s members page/ | 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 | else | 114 | else |
115 | begin | 115 | begin |
@@ -122,6 +122,11 @@ module NavigationHelpers | @@ -122,6 +122,11 @@ module NavigationHelpers | ||
122 | end | 122 | end |
123 | end | 123 | end |
124 | end | 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 | end | 130 | end |
126 | 131 | ||
127 | World(NavigationHelpers) | 132 | World(NavigationHelpers) |