Skip to content

Commit

Permalink
Communities page breadcrumbs should link back to /communities/home
Browse files Browse the repository at this point in the history
  • Loading branch information
camillevilla committed Oct 14, 2022
1 parent 3fd2d3c commit e21058f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module NavigationHelper
RETURN_TO_TOP_PAGES = ['show', 'metrics', 'introduction', 'overview', 'implementation']
PRACTICE_EDITOR_PAGES = ['introduction', 'editors', 'overview', 'implementation', 'adoptions', 'about']
COMMUNITIES = ['xr-network']

def setup_breadcrumb_navigation
session[:breadcrumbs] = session[:breadcrumbs] || []
Expand Down Expand Up @@ -235,6 +236,9 @@ def add_landing_page_breadcrumb(path)

if @page_slug == 'home'
empty_breadcrumbs
elsif COMMUNITIES.include?(@page.page_group.slug) && @builder_landing_page.exists?
empty_breadcrumbs
add_landing_page_breadcrumb("/communities/#{params[:page_group_friendly_id]}")
elsif @builder_landing_page.exists?
empty_breadcrumbs
add_landing_page_breadcrumb("/#{params[:page_group_friendly_id]}")
Expand Down
13 changes: 8 additions & 5 deletions spec/features/shared/breadcrumbs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
PracticePartnerPractice.create!(practice_partner: @pp, practice: @user_practice)
@page_group = PageGroup.create!(name: 'programming', description: 'Pages about programming go in this group.')
@page_group2 = PageGroup.create!(name: 'test', description: 'Pages about tests go in this group.')
@community_page_group = PageGroup.create!(name: 'xr-network', description: 'Pages related to a community')
@page = Page.create!(title: 'Test', description: 'This is a test page', slug: 'home', page_group: @page_group, published: Time.now)
@page2 = Page.create!(title: 'Test', description: 'This is a test page', slug: 'test-page', page_group: @page_group2, published: Time.now)
@page3 = Page.create!(title: 'Test', description: 'This is a test page', slug: 'test-page', page_group: @page_group, published: Time.now)
@community_home_page = Page.create!(title: 'Community home page', description: 'This is a community home page', slug: 'home', page_group: @community_page_group, published: Time.now)
@community_sub_page = Page.create!(title: 'Community subpage', description: 'This is a community subpage', slug: 'test-page', page_group: @community_page_group, published: Time.now)
visit '/'
end

Expand Down Expand Up @@ -292,12 +295,12 @@
expect(page).to_not have_css('#breadcrumbs')
end

it 'only provides a single breadcrumb for /communities subpages' do
visit '/communities/programming/test-page'
it 'provides a single breadcrumb for /communities subpages' do
visit '/communities/xr-network/test-page'
expect(page).to have_css('#breadcrumbs', visible: true)
expect(page).to have_css('.usa-breadcrumb__link', text: @page_group.name)
expect(page).to have_link(href: '/programming')
expect(page).not_to have_css('.usa-breadcrumb__link', text: @page.title)
expect(page).to have_css('.usa-breadcrumb__link', text: @community_page_group.name)
expect(page).to have_link(href: '/communities/xr-network')
expect(page).not_to have_css('.usa-breadcrumb__link', text: @community_sub_page.title)
end
end
end

0 comments on commit e21058f

Please sign in to comment.