From 7a30b8ec002bf8f8f4cf6fbaac308ec5ba670ce8 Mon Sep 17 00:00:00 2001 From: Simon Hughesdon Date: Thu, 19 Sep 2019 17:48:16 +0100 Subject: [PATCH] Ensure that FAQs are generated correctly The logic for guides was incorrect so the body of the default guide chapter wasn't being passed to the machine readable component. --- app/views/content_items/guide.html.erb | 2 +- test/integration/answer_test.rb | 1 + test/integration/guide_test.rb | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/content_items/guide.html.erb b/app/views/content_items/guide.html.erb index 1be4779e2..1924dab20 100644 --- a/app/views/content_items/guide.html.erb +++ b/app/views/content_items/guide.html.erb @@ -2,7 +2,7 @@ <%= machine_readable_metadata( schema: :faq, canonical_url: @content_item.canonical_url, - body: @content_item.has_valid_part? ? @content_item.current_part_body : nil + body: @content_item.has_parts? ? @content_item.current_part_body : nil ) %> <% end %> diff --git a/test/integration/answer_test.rb b/test/integration/answer_test.rb index 8fca111c5..83028f7ad 100644 --- a/test/integration/answer_test.rb +++ b/test/integration/answer_test.rb @@ -26,5 +26,6 @@ class AnswerTest < ActionDispatch::IntegrationTest faq_schema = find_structured_data(page, "FAQPage") assert_equal faq_schema["headline"], @content_item['title'] + assert_not_equal faq_schema["mainEntity"], [] end end diff --git a/test/integration/guide_test.rb b/test/integration/guide_test.rb index d4ab510cc..beefd22c9 100644 --- a/test/integration/guide_test.rb +++ b/test/integration/guide_test.rb @@ -82,6 +82,7 @@ class GuideTest < ActionDispatch::IntegrationTest faq_schema = find_structured_data(page, "FAQPage") assert_equal faq_schema["headline"], @content_item['title'] + assert_not_equal faq_schema["mainEntity"], [] end test "guide chapters show the faq schema" do @@ -89,6 +90,7 @@ class GuideTest < ActionDispatch::IntegrationTest faq_schema = find_structured_data(page, "FAQPage") assert_equal faq_schema["headline"], @content_item['title'] + assert_not_equal faq_schema["mainEntity"], [] end def setup_and_visit_part_in_guide