From 7fe87b34908774d7760904acc52ba75acba82724 Mon Sep 17 00:00:00 2001 From: Max Harden Date: Wed, 17 Nov 2021 22:06:07 +0000 Subject: [PATCH] Fix variable scope of context boolean --- app/views/content_items/_context_and_title.html.erb | 7 +++++-- test/views/content_items/attachments.html.erb_test.rb | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/content_items/_context_and_title.html.erb b/app/views/content_items/_context_and_title.html.erb index b3cc6adc6..c68512a07 100644 --- a/app/views/content_items/_context_and_title.html.erb +++ b/app/views/content_items/_context_and_title.html.erb @@ -1,4 +1,7 @@ -<% context_string = t("content_item.schema_name.#{@content_item.document_type}", count: 1) %> +<% + context_string = t("content_item.schema_name.#{@content_item.document_type}", count: 1); + context_inside = false; + %> <% @content_item&.featured_attachments.each do |fa| %> <% return if !@content_item.attachment_details(fa).present? %> @@ -17,7 +20,7 @@ <%= render 'govuk_publishing_components/components/title', context: context_string, context_locale: t_locale_fallback("content_item.schema_name.#{@content_item.document_type}", count: 1), - context_inside: context_inside ||= false, + context_inside: context_inside, title: @content_item.title, average_title_length: "long" %> diff --git a/test/views/content_items/attachments.html.erb_test.rb b/test/views/content_items/attachments.html.erb_test.rb index b89a04659..64aea883c 100644 --- a/test/views/content_items/attachments.html.erb_test.rb +++ b/test/views/content_items/attachments.html.erb_test.rb @@ -60,5 +60,6 @@ class ContentItemsAttachmentsTest < ActionView::TestCase ) assert_includes rendered, "Correspondence overview:" + assert_select "h1 span" end end