Skip to content

Commit

Permalink
Remove hardcoded FAQPage schema
Browse files Browse the repository at this point in the history
We used this approach for the lead up to the election to present better
search results in Google informing people of voting process.  This has a lot
of manual overhead and requires much back and forth between content, product
and tech.  There's little reason for us to do this now that the election has
completed, so let's just revert to the standard schemas.

When we work out a method of better automating this, it should be revisited.
  • Loading branch information
sihugh committed Dec 16, 2019
1 parent d805605 commit 45c8cea
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 173 deletions.
69 changes: 0 additions & 69 deletions app/presenters/machine_readable/yaml_faq_page_schema_presenter.rb

This file was deleted.

4 changes: 1 addition & 3 deletions app/views/content_items/guide_single.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
) %>
<% end %>

<% if MachineReadable::YamlFaqPageSchemaPresenter.configured?(@content_item) %>
<script type="application/ld+json">
<%= raw MachineReadable::YamlFaqPageSchemaPresenter.new(@content_item).structured_data.to_json %>
<%= raw MachineReadable::GuideFaqPageSchemaPresenter.new(@content_item).structured_data.to_json %>
</script>
<% end %>

<% content_for :simple_header, true %>

Expand Down
87 changes: 0 additions & 87 deletions config/machine_readable/voting-in-the-uk.yml

This file was deleted.

14 changes: 0 additions & 14 deletions test/integration/guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@ class GuideTest < ActionDispatch::IntegrationTest
assert_nil faq_schema
end

# The schema config is in /config/machine_readable/voting-in-the-uk.yml
test "voting in the UK guide shows hard coded FAQ schema" do
setup_and_visit_voting_guide

faq_schema = find_structured_data(page, "FAQPage")
q_and_as = faq_schema["mainEntity"]

assert_equal faq_schema["@type"], "FAQPage"
assert_equal faq_schema["headline"], "How to vote"
assert_equal faq_schema["description"], "<p>You need to <a href=\"/register-to-vote?src=schema\">register to vote</a> before you can vote in UK elections or referendums.</p> <p>If you’re eligible, you can vote in person on the day of the election at a named polling station. You can also apply for a postal or proxy vote instead.</p>\n"

assert_equal 8, q_and_as.count
end

test "voting in the UK guide shows all chapters on a single page" do
content_item = setup_and_visit_voting_guide
part_titles = content_item["details"]["parts"].map { |part| part["title"] }
Expand Down

0 comments on commit 45c8cea

Please sign in to comment.