Skip to content

Commit

Permalink
Merge pull request #2938 from alphagov/fix-edition-factory
Browse files Browse the repository at this point in the history
Move factory to live edition factory file
  • Loading branch information
yndajas authored Oct 24, 2024
2 parents d39dca3 + e3fe928 commit 68a73e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 0 additions & 12 deletions spec/factories/edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,4 @@
schema_name { "contact" }
document_type { "contact" }
end

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

transient do
embedded_content_id { SecureRandom.uuid }
embedded_content_type { "content_block_email_address" }
links_hash { { embed: [embedded_content_id] } }
end
end
end
11 changes: 11 additions & 0 deletions spec/factories/live_edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
with_draft
end

trait :with_embedded_content 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

after(:create) do |live_edition, evaluator|
unless evaluator.published_at
live_edition.update!(published_at: live_edition.created_at)
Expand Down
3 changes: 2 additions & 1 deletion spec/service_consumers/pact_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@ def url_encode(str)
reusable_edition = create(:live_edition, document: reusable_document)

document = create(:document, content_id: "d66d6552-2627-4451-9dbc-cadbbd2005a1")
live_edition_with_embedded_edition = create(:live_edition_with_embedded_content,
live_edition_with_embedded_edition = create(:live_edition,
:with_embedded_content,
document:,
embedded_content_id: reusable_edition.content_id,
title: "foo",
Expand Down

0 comments on commit 68a73e6

Please sign in to comment.