Skip to content

Commit

Permalink
Merge pull request #167 from alphagov/manual
Browse files Browse the repository at this point in the history
Include `manual` field in synced documents
  • Loading branch information
csutter authored Jan 5, 2024
2 parents 3efb9f0 + 6486564 commit 2c2f33d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/concerns/publishing_api/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def metadata
world_locations:,
organisations:,
topical_events:,
manual:,
parts:,
}.compact_blank
end
Expand Down Expand Up @@ -101,6 +102,13 @@ def topical_events
&.map { _1[:base_path].split("/").last }
end

def manual
document_hash
.dig(:expanded_links, :manual)
&.first
&.dig(:base_path)
end

def parts
document_hash
.dig(:details, :parts)
Expand Down
1 change: 1 addition & 0 deletions spec/integration/document_synchronization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
is_historic: 0,
content_purpose_supergroup: "guidance_and_regulation",
organisations: %w[driver-and-vehicle-standards-agency],
manual: "/guidance/mot-inspection-manual-for-private-passenger-and-light-commercial-vehicles",
locale: "en",
},
content: a_string_matching(/<h2 id="section-6-1">6\.1\. Structure.+<\/table>\n\n/m),
Expand Down
18 changes: 18 additions & 0 deletions spec/models/concerns/publishing_api/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,24 @@
end
end

describe "manual" do
subject(:extracted_manual) { extracted_metadata[:manual] }

let(:document_hash) { { expanded_links: { manual: } } }

context "without a manual" do
let(:manual) { nil }

it { is_expected.to be_nil }
end

context "with a manual" do
let(:manual) { [{ base_path: "/guidance/reticulating-splines" }] }

it { is_expected.to eq("/guidance/reticulating-splines") }
end
end

describe "parts" do
subject(:extracted_parts) { extracted_metadata[:parts] }

Expand Down

0 comments on commit 2c2f33d

Please sign in to comment.