add more specs
This commit is contained in:
committed by
Pete Matsyburka
parent
6f90147a11
commit
178ee47093
+43
-32
@@ -7,7 +7,11 @@ FactoryBot.define do
|
||||
author factory: %i[user]
|
||||
name { Faker::Book.title }
|
||||
|
||||
after(:create) do |template|
|
||||
transient do
|
||||
submitter_count { 1 }
|
||||
end
|
||||
|
||||
after(:create) do |template, evaluator|
|
||||
blob = ActiveStorage::Blob.create_and_upload!(
|
||||
io: Rails.root.join('spec/fixtures/sample-document.pdf').open,
|
||||
filename: 'sample-document.pdf',
|
||||
@@ -22,39 +26,46 @@ FactoryBot.define do
|
||||
Templates::ProcessDocument.call(attachment, attachment.download)
|
||||
|
||||
template.schema = [{ attachment_uuid: attachment.uuid, name: 'sample-document' }]
|
||||
template.submitters = [
|
||||
number_words = %w[first second third fourth fifth sixth seventh eighth ninth tenth]
|
||||
|
||||
template.submitters = Array.new(evaluator.submitter_count) do |i|
|
||||
{
|
||||
'name' => 'First Party',
|
||||
'uuid' => '513848eb-1096-4abc-a743-68596b5aaa4c'
|
||||
'name' => "#{number_words[i]&.capitalize} Party",
|
||||
'uuid' => SecureRandom.uuid
|
||||
}
|
||||
]
|
||||
template.fields = [
|
||||
{
|
||||
'uuid' => '21637fc9-0655-45df-8952-04ec64949e85',
|
||||
'submitter_uuid' => '513848eb-1096-4abc-a743-68596b5aaa4c',
|
||||
'name' => 'First Name',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'areas' => [
|
||||
{
|
||||
'x' => 0.09027777777777778,
|
||||
'y' => 0.1197252208047105,
|
||||
'w' => 0.3069444444444444,
|
||||
'h' => 0.03336604514229637,
|
||||
'attachment_uuid' => attachment.uuid,
|
||||
'page' => 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'uuid' => '1f97f8e3-dc82-4586-aeea-6ebed6204e46',
|
||||
'submitter_uuid' => '513848eb-1096-4abc-a743-68596b5aaa4c',
|
||||
'name' => '',
|
||||
'type' => 'signature',
|
||||
'required' => true,
|
||||
'areas' => []
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
template.fields = template.submitters.reduce([]) do |fields, submitter|
|
||||
fields += [
|
||||
{
|
||||
'uuid' => SecureRandom.uuid,
|
||||
'submitter_uuid' => submitter['uuid'],
|
||||
'name' => 'First Name',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'areas' => [
|
||||
{
|
||||
'x' => 0.09027777777777778,
|
||||
'y' => 0.1197252208047105,
|
||||
'w' => 0.3069444444444444,
|
||||
'h' => 0.03336604514229637,
|
||||
'attachment_uuid' => attachment.uuid,
|
||||
'page' => 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'uuid' => SecureRandom.uuid,
|
||||
'submitter_uuid' => submitter['uuid'],
|
||||
'name' => '',
|
||||
'type' => 'signature',
|
||||
'required' => true,
|
||||
'areas' => []
|
||||
}
|
||||
]
|
||||
|
||||
fields
|
||||
end
|
||||
|
||||
template.save!
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user