Commit 1a57fd09fc736c8b0b586b96cf2f31fd5fa6e53c

Authored by Antonio Terceiro
2 parents 84ca7256 5b9ea251

Merge branch 'increase_breadcrumbs_reach' into 'master'

Include some profile controller paths to show breadcrumbs block

Currently, pages from profile and event actions don't display breadcrumbs. This merge creates path links on profile and event actions page with profile index as ancestor, so breadcrumbs block will work on these pages.

See merge request !728
plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
@@ -31,6 +31,9 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block @@ -31,6 +31,9 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block
31 id = params[:id] || params[:parent_id] 31 id = params[:id] || params[:parent_id]
32 links = page_trail(Article.find(id)) if id 32 links = page_trail(Article.find(id)) if id
33 links << { :name => cms_action(params[:action]), :url => params } if show_cms_action 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 end 37 end
35 links 38 links
36 end 39 end
@@ -74,9 +77,14 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block @@ -74,9 +77,14 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block
74 protected 77 protected
75 78
76 CMS_ACTIONS = {:edit => c_('Edit'), :upload_files => _('Upload Files'), :new => c_('New')} 79 CMS_ACTIONS = {:edit => c_('Edit'), :upload_files => _('Upload Files'), :new => c_('New')}
  80 + PROFILE_ACTIONS = {:members => _('Members'), :events => _('Events')}
77 81
78 def cms_action(action) 82 def cms_action(action)
79 CMS_ACTIONS[action.to_sym] || action 83 CMS_ACTIONS[action.to_sym] || action
80 end 84 end
81 85
  86 + def profile_action(action)
  87 + PROFILE_ACTIONS[action.to_sym] || action
  88 + end
  89 +
82 end 90 end
plugins/breadcrumbs/test/unit/content_breadcrumbs_block_test.rb
@@ -40,6 +40,24 @@ class ContentBreadcrumbsBlockTest &lt; ActiveSupport::TestCase @@ -40,6 +40,24 @@ class ContentBreadcrumbsBlockTest &lt; ActiveSupport::TestCase
40 assert_equal links, @block.page_trail(nil, params) 40 assert_equal links, @block.page_trail(nil, params)
41 end 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 should 'include profile link on path of links to reach a page' do 61 should 'include profile link on path of links to reach a page' do
44 links = [{:name => @profile.name, :url => @profile.url}, {:name => @folder.name, :url => @folder.url}, {:name => @article.name, :url => @article.url}] 62 links = [{:name => @profile.name, :url => @profile.url}, {:name => @folder.name, :url => @folder.url}, {:name => @article.name, :url => @article.url}]
45 assert_equal links, @block.trail(@article, @profile) 63 assert_equal links, @block.trail(@article, @profile)