Commit 741e19aedc3f4b45846bfa272618f32f214443e4
Committed by
Victor Costa
1 parent
95fdfbab
Exists in
theme-brasil-digital-from-staging
and in
4 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
... | ... | @@ -31,6 +31,9 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block |
31 | 31 | id = params[:id] || params[:parent_id] |
32 | 32 | links = page_trail(Article.find(id)) if id |
33 | 33 | links << { :name => cms_action(params[:action]), :url => params } if show_cms_action |
34 | + elsif (params[:controller] == 'profile' || params[:controller] == 'events') | |
35 | + links << { :name => _('Profile'), :url => {:controller=> 'profile', :action =>'index', :profile =>params[:profile]}} | |
36 | + links << { :name => profile_action(params[:action]), :url => params } unless params[:action] == 'index' | |
34 | 37 | end |
35 | 38 | links |
36 | 39 | end |
... | ... | @@ -74,9 +77,14 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block |
74 | 77 | protected |
75 | 78 | |
76 | 79 | CMS_ACTIONS = {:edit => c_('Edit'), :upload_files => _('Upload Files'), :new => c_('New')} |
80 | + PROFILE_ACTIONS = {:members => _('Members'), :events => _('Events')} | |
77 | 81 | |
78 | 82 | def cms_action(action) |
79 | 83 | CMS_ACTIONS[action.to_sym] || action |
80 | 84 | end |
81 | 85 | |
86 | + def profile_action(action) | |
87 | + PROFILE_ACTIONS[action.to_sym] || action | |
88 | + end | |
89 | + | |
82 | 90 | 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) | ... | ... |