Commit 5b9ea2513b90770ccafd42e5ce571090b2f4fc3f
1 parent
5641033f
Exists in
master
and in
20 other branches
Include some profile controller paths to show breadcrumbs block
Showing
2 changed files
with
26 additions
and
0 deletions
Show diff stats
plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
... | ... | @@ -23,6 +23,9 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block |
23 | 23 | id = params[:id] || params[:parent_id] |
24 | 24 | links = page_trail(Article.find(id)) if id |
25 | 25 | links << { :name => cms_action(params[:action]), :url => params } if show_cms_action |
26 | + elsif (params[:controller] == 'profile' || params[:controller] == 'events') | |
27 | + links << { :name => _('Profile'), :url => {:controller=> 'profile', :action =>'index', :profile =>params[:profile]}} | |
28 | + links << { :name => profile_action(params[:action]), :url => params } unless params[:action] == 'index' | |
26 | 29 | end |
27 | 30 | links |
28 | 31 | end |
... | ... | @@ -66,9 +69,14 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block |
66 | 69 | protected |
67 | 70 | |
68 | 71 | CMS_ACTIONS = {:edit => c_('Edit'), :upload_files => _('Upload Files'), :new => c_('New')} |
72 | + PROFILE_ACTIONS = {:members => _('Members'), :events => _('Events')} | |
69 | 73 | |
70 | 74 | def cms_action(action) |
71 | 75 | CMS_ACTIONS[action.to_sym] || action |
72 | 76 | end |
73 | 77 | |
78 | + def profile_action(action) | |
79 | + PROFILE_ACTIONS[action.to_sym] || action | |
80 | + end | |
81 | + | |
74 | 82 | end | ... | ... |
plugins/breadcrumbs/test/unit/content_breadcrumbs_block_test.rb
... | ... | @@ -40,6 +40,24 @@ class ContentBreadcrumbsBlockTest < ActiveSupport::TestCase |
40 | 40 | assert_equal links, @block.page_trail(nil, params) |
41 | 41 | end |
42 | 42 | |
43 | + should 'include profile page link on path of links to reach a profile controller page' do | |
44 | + params = {:controller => 'profile', :action => 'members', :profile => @profile.identifier} | |
45 | + links = [{:name => 'Profile', :url => {:controller => 'profile', :action => 'index', :profile => @profile.identifier}}, {:name => 'Members', :url => {:controller=>'profile', :action=>'members', :profile=> @profile.identifier}}] | |
46 | + assert_equal links, @block.page_trail(nil, params) | |
47 | + end | |
48 | + | |
49 | + should 'include only the profile page link on path links when profile action is index' do | |
50 | + params = {:controller => 'profile', :action => 'index', :profile => @profile.identifier} | |
51 | + links = [{:name => 'Profile', :url => {:controller => 'profile', :action => 'index', :profile => @profile.identifier}}] | |
52 | + assert_equal links, @block.page_trail(nil, params) | |
53 | + end | |
54 | + | |
55 | + should 'profile page be the ancestor page of event profile page calendar' do | |
56 | + params = {:controller => 'profile', :action => 'events', :profile => @profile.identifier} | |
57 | + links = [{:name => 'Profile', :url => {:controller => 'profile', :action => 'index', :profile => @profile.identifier}}, {:name => 'Events', :url => {:controller=>'profile', :action=>'events', :profile=> @profile.identifier}}] | |
58 | + assert_equal links, @block.page_trail(nil, params) | |
59 | + end | |
60 | + | |
43 | 61 | should 'include profile link on path of links to reach a page' do |
44 | 62 | links = [{:name => @profile.name, :url => @profile.url}, {:name => @folder.name, :url => @folder.url}, {:name => @article.name, :url => @article.url}] |
45 | 63 | assert_equal links, @block.trail(@article, @profile) | ... | ... |
-
mentioned in commit b01e1b772990a56f7d2c009186672211915c182d