Skip to content

Commit

Permalink
Merge pull request #2855 from alphagov/content-modelling/450-pact-hel…
Browse files Browse the repository at this point in the history
…pers-for-getting-content-with-embeds

Content modelling/450 pact helpers for getting content with embeds
  • Loading branch information
tahb authored Aug 29, 2024
2 parents 8c5b3d9 + 24510ae commit 6413982
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/factories/edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,15 @@
schema_name { "contact" }
document_type { "contact" }
end

factory :edition_with_embedded_content, parent: :edition do
base_path { "/#{SecureRandom.uuid}" }
details { { body: "{{embed:#{embedded_content_type}:#{embedded_content_id}" } }

transient do
embedded_content_id { SecureRandom.uuid }
embedded_content_type { "content_block_email_address" }
links_hash { { embed: [embedded_content_id] } }
end
end
end
31 changes: 31 additions & 0 deletions spec/service_consumers/pact_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,4 +650,35 @@ def url_encode(str)
create(:live_edition, base_path: "/4", document: document4, updated_at: "2017-04-01T00:00:00Z", published_at: "2017-04-01T00:00:00Z")
end
end

provider_state "a content item exists (content_id: d66d6552-2627-4451-9dbc-cadbbd2005a1) that embeds the reusable content (content_id: bed722e6-db68-43e5-9079-063f623335a7)" do
set_up do
reusable_document = create(:document, content_id: "bed722e6-db68-43e5-9079-063f623335a7")
reusable_edition = create(:live_edition, document: reusable_document)

document = create(:document, content_id: "d66d6552-2627-4451-9dbc-cadbbd2005a1")
edition_with_embedded_edition = create(:edition_with_embedded_content,
document:,
embedded_content_id: reusable_edition.content_id,
title: "foo",
base_path: "/foo",
document_type: "publication")

organisation_document = create(:document, content_id: "d1e7d343-9844-4246-a469-1fa4640e12ad")
primary_publishing_organisation = create(:live_edition,
document: organisation_document,
title: "bar",
document_type: "organisation",
schema_name: "organisation",
base_path: "/bar")
create(
:link,
edition: edition_with_embedded_edition,
link_type: :primary_publishing_organisation,
link_set: nil,
position: 0,
target_content_id: primary_publishing_organisation.content_id,
)
end
end
end

0 comments on commit 6413982

Please sign in to comment.