Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content modelling/450 pact helpers for getting content with embeds #2855

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a link with link_type: :embed somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we do 👍 I added this to the new factory which is perhaps too mysterious and could be made explicit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, I see - that's fine, I just didn't follow it all the way through. No need to be any more explicit I don't think.

link_set: nil,
position: 0,
target_content_id: primary_publishing_organisation.content_id,
)
end
end
end