Skip to content

Commit

Permalink
Ensure that FAQs are generated correctly
Browse files Browse the repository at this point in the history
The logic for guides was incorrect so the body of the default guide chapter
wasn't being passed to the machine readable component.
  • Loading branch information
sihugh committed Sep 19, 2019
1 parent 15bb924 commit 7a30b8e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/content_items/guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

Expand Down
1 change: 1 addition & 0 deletions test/integration/answer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/integration/guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ 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
setup_and_visit_part_in_guide
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
Expand Down

0 comments on commit 7a30b8e

Please sign in to comment.