Skip to content

Commit

Permalink
Merge pull request #4295 from alphagov/fix_breadcrumb_duplication
Browse files Browse the repository at this point in the history
Fix breadcrumb duplication
  • Loading branch information
JamesCGDS authored Oct 18, 2024
2 parents 6433177 + 177b175 commit 7f67002
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/models/content_item.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ContentItem
attr_reader :content_store_response, :content_store_hash, :body, :image, :description,
:document_type, :schema, :title, :base_path, :locale
:document_type, :schema_name, :title, :base_path, :locale

# SCAFFOLDING: remove the override_content_store_hash parameter when full landing page
# content items including block details are available from content-store
Expand All @@ -12,7 +12,7 @@ def initialize(content_store_response, override_content_store_hash: nil)
@image = content_store_hash.dig("details", "image")
@description = content_store_hash["description"]
@document_type = content_store_hash["document_type"]
@schema = content_store_hash["schema"]
@schema_name = content_store_hash["schema_name"]
@title = content_store_hash["title"]
@base_path = content_store_hash["base_path"]
@locale = content_store_hash["locale"]
Expand All @@ -29,7 +29,7 @@ def respond_to_missing?(method_name, _include_private = false)

def method_missing(method_name, *_args, &_block)
if method_name.to_s =~ REGEX_IS_A
schema == ::Regexp.last_match(1)
schema_name == ::Regexp.last_match(1)
else
super
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/landing_page/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="landing-page-header__blue-bar">
</div>

<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: Hash.new, inverse: true %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: content_item_hash, inverse: true %>

<div class="landing-page-header__org">
<%= render "govuk_publishing_components/components/organisation_logo", {
Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def dummy_publication

describe "#remove_breadcrumbs" do
describe "when is_landing_page? is true" do
let(:content_item) { ContentItem.new({ "schema" => "landing_page" }) }
let(:content_item) { ContentItem.new({ "schema_name" => "landing_page" }) }

it "removes breadcrumbs" do
expect(remove_breadcrumbs(content_item)).to eq(true)
end
end

describe "when is_landing_page? is false" do
let(:content_item) { ContentItem.new({ "schema" => "a_different_page" }) }
let(:content_item) { ContentItem.new({ "schema_name" => "a_different_page" }) }

it "does not remove breadcrumbs" do
expect(remove_breadcrumbs(content_item)).to eq(false)
Expand Down
6 changes: 3 additions & 3 deletions spec/models/content_item_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
RSpec.describe ContentItem do
describe "#is_a_xxxx?" do
let(:subject) { described_class.new({ "schema" => "landing_page" }) }
let(:subject) { described_class.new({ "schema_name" => "landing_page" }) }

it "returns true when called with the schema of the object" do
it "returns true when called with the schema name of the object" do
expect(subject.is_a_landing_page?).to be true
end

it "returns false when called with a mismatching schema" do
it "returns false when called with a mismatching schema name" do
expect(subject.is_a_place?).to be false
end

Expand Down

0 comments on commit 7f67002

Please sign in to comment.