From e21058f2381301a6c9a0e219349cb648af6d8400 Mon Sep 17 00:00:00 2001 From: Camille Villa <5402927+camillevilla@users.noreply.github.com> Date: Fri, 14 Oct 2022 14:34:01 -0700 Subject: [PATCH] Communities page breadcrumbs should link back to /communities/home --- app/helpers/navigation_helper.rb | 4 ++++ spec/features/shared/breadcrumbs_spec.rb | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index 373a1a48eb..ac300a060b 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -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] || [] @@ -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]}") diff --git a/spec/features/shared/breadcrumbs_spec.rb b/spec/features/shared/breadcrumbs_spec.rb index 80a4eb1dfa..a1cbb11fdd 100644 --- a/spec/features/shared/breadcrumbs_spec.rb +++ b/spec/features/shared/breadcrumbs_spec.rb @@ -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 @@ -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