Skip to content

Commit

Permalink
Merge pull request #888 from alphagov/update-howto
Browse files Browse the repository at this point in the history
Remove step by steps from CreativeWork schema
  • Loading branch information
sihugh authored May 24, 2019
2 parents 739f207 + 4955071 commit 594a570
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 80 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

* Update notice component to render without title (PR #884)
* Add margin option to notice component (PR #884)
* Remove related step by steps from CreativeWork schema (PR #888)

# 16.23.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,13 @@ def publishing_organisation
end

def is_part_of
return {} unless step_by_step_schemas.any? || document_collections.any?
return {} unless document_collections.any?

{
"isPartOf" => document_collections + step_by_step_schemas
"isPartOf" => document_collections
}
end

def step_by_step_schemas
# We could include `related_to_step_navs` eventually too, but initially
# link to those that we render in the "step_by_step_nav_related" component
@step_by_step_schemas ||= fetch_step_by_step_schemas
end

def fetch_step_by_step_schemas
page.content_item.dig("links", "part_of_step_navs").to_a.map do |step_by_step|
step_by_step_page = linked_page(step_by_step)
structured_data = HowToSchema.new(step_by_step_page.canonical_url).structured_data

structured_data.merge(image_schema)
end
end

def linked_page(step_by_step)
Page.new(
content_item: step_by_step,
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion lib/govuk_publishing_components/presenters/schema_org.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'govuk_publishing_components/presenters/machine_readable/page'
require 'govuk_publishing_components/presenters/machine_readable/article_schema'
require 'govuk_publishing_components/presenters/machine_readable/creative_work_schema'
require 'govuk_publishing_components/presenters/machine_readable/how_to_schema'
require 'govuk_publishing_components/presenters/machine_readable/has_part_schema'
require 'govuk_publishing_components/presenters/machine_readable/is_part_of_schema'
require 'govuk_publishing_components/presenters/machine_readable/news_article_schema'
Expand Down
42 changes: 0 additions & 42 deletions spec/lib/govuk_publishing_components/presenters/schema_org_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,48 +186,6 @@
expect(structured_data['author']['name']).to eql("Foo org")
end

it "links to step by steps that it belongs to" do
content_item = GovukSchemas::RandomExample.for_schema(frontend_schema: "answer") do |random_item|
random_item.merge(
"first_published_at" => "2017-09-04T13:50:49.000+00:00",
"links" => {
"part_of_step_navs" => [
{
"api_path" => "/api/content/employ-someone",
"base_path" => "/employ-someone",
"content_id" => "47bcdf4c-9df9-48ff-b1ad-2381ca819464",
"description" => "Employ someone: agree a contract, right to work checks, DBS checks, workplace pensions, set up PAYE, tell HMRC",
"details" => {},
"document_type" => "step_by_step_nav",
"locale" => "en",
"public_updated_at" => "2018-06-22T12:12:38Z",
"schema_name" => "step_by_step_nav",
"title" => "Employ someone: step by step",
"api_url" => "https://www.gov.uk/api/content/employ-someone",
"web_url" => "https://www.gov.uk/employ-someone"
}
],
"primary_publishing_organisation" => [
{
"content_id" => "d944229b-a5ad-453d-8e16-cb5dcfcdb866",
"title" => "Foo org",
"locale" => "en",
"base_path" => "/orgs/foo",
}
]
}
)
end

structured_data = generate_structured_data(
content_item: content_item,
schema: :article
).structured_data

expect(structured_data['isPartOf'][0]['@type']).to eq('HowTo')
expect(structured_data['isPartOf'][0]['sameAs']).to eq('http://www.dev.gov.uk/employ-someone')
end

it "adds an image if it's available" do
content_item = GovukSchemas::RandomExample.for_schema(frontend_schema: "news_article") do |random_item|
random_item["details"]["image"] = { "url" => "/foo" }
Expand Down

0 comments on commit 594a570

Please sign in to comment.