|
|
|
@ -9,6 +9,7 @@ FactoryBot.define do
|
|
|
|
|
|
|
|
|
|
|
|
transient do
|
|
|
|
transient do
|
|
|
|
submitter_count { 1 }
|
|
|
|
submitter_count { 1 }
|
|
|
|
|
|
|
|
attachment_count { 1 }
|
|
|
|
only_field_types do
|
|
|
|
only_field_types do
|
|
|
|
%w[text date checkbox radio signature number multiple select initials image file stamp cells phone payment]
|
|
|
|
%w[text date checkbox radio signature number multiple select initials image file stamp cells phone payment]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@ -16,6 +17,19 @@ FactoryBot.define do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
after(:create) do |template, ev|
|
|
|
|
after(:create) do |template, ev|
|
|
|
|
|
|
|
|
number_words = %w[first second third fourth fifth sixth seventh eighth ninth tenth]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template.submitters = Array.new(ev.submitter_count) do |i|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
'name' => "#{number_words[i]&.capitalize} Party",
|
|
|
|
|
|
|
|
'uuid' => SecureRandom.uuid
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ev.attachment_count.times do |i|
|
|
|
|
|
|
|
|
attachment_index = i + 1 if i > 0
|
|
|
|
|
|
|
|
field_index = "(#{attachment_index})" if attachment_index
|
|
|
|
|
|
|
|
|
|
|
|
blob = ActiveStorage::Blob.create_and_upload!(
|
|
|
|
blob = ActiveStorage::Blob.create_and_upload!(
|
|
|
|
io: Rails.root.join('spec/fixtures/sample-document.pdf').open,
|
|
|
|
io: Rails.root.join('spec/fixtures/sample-document.pdf').open,
|
|
|
|
filename: 'sample-document.pdf',
|
|
|
|
filename: 'sample-document.pdf',
|
|
|
|
@ -29,22 +43,17 @@ FactoryBot.define do
|
|
|
|
|
|
|
|
|
|
|
|
Templates::ProcessDocument.call(attachment, attachment.download)
|
|
|
|
Templates::ProcessDocument.call(attachment, attachment.download)
|
|
|
|
|
|
|
|
|
|
|
|
template.schema = [{ attachment_uuid: attachment.uuid, name: 'sample-document' }]
|
|
|
|
template.schema << {
|
|
|
|
number_words = %w[first second third fourth fifth sixth seventh eighth ninth tenth]
|
|
|
|
attachment_uuid: attachment.uuid,
|
|
|
|
|
|
|
|
name: ['sample-document', attachment_index].compact.join('-')
|
|
|
|
template.submitters = Array.new(ev.submitter_count) do |i|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
'name' => "#{number_words[i]&.capitalize} Party",
|
|
|
|
|
|
|
|
'uuid' => SecureRandom.uuid
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template.fields = template.submitters.reduce([]) do |fields, submitter|
|
|
|
|
template.fields += template.submitters.reduce([]) do |fields, submitter|
|
|
|
|
fields += [
|
|
|
|
fields += [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'First Name',
|
|
|
|
'name' => ['First Name', field_index].compact.join(' '),
|
|
|
|
'type' => 'text',
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -62,7 +71,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Birthday',
|
|
|
|
'name' => ['Birthday', field_index].compact.join(' '),
|
|
|
|
'type' => 'date',
|
|
|
|
'type' => 'date',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => { 'format' => 'DD/MM/YYYY' },
|
|
|
|
'preferences' => { 'format' => 'DD/MM/YYYY' },
|
|
|
|
@ -80,7 +89,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Do you agree?',
|
|
|
|
'name' => ['Do you agree?', field_index].compact.join(' '),
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -98,7 +107,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'First child',
|
|
|
|
'name' => ['First child', field_index].compact.join(' '),
|
|
|
|
'type' => 'radio',
|
|
|
|
'type' => 'radio',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -120,7 +129,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Signature',
|
|
|
|
'name' => ['Signature', field_index].compact.join(' '),
|
|
|
|
'type' => 'signature',
|
|
|
|
'type' => 'signature',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -138,7 +147,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'House number',
|
|
|
|
'name' => ['House number', field_index].compact.join(' '),
|
|
|
|
'type' => 'number',
|
|
|
|
'type' => 'number',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -156,7 +165,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Colors',
|
|
|
|
'name' => ['Colors', field_index].compact.join(' '),
|
|
|
|
'type' => 'multiple',
|
|
|
|
'type' => 'multiple',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -179,7 +188,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Gender',
|
|
|
|
'name' => ['Gender', field_index].compact.join(' '),
|
|
|
|
'type' => 'select',
|
|
|
|
'type' => 'select',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -201,7 +210,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Initials',
|
|
|
|
'name' => ['Initials', field_index].compact.join(' '),
|
|
|
|
'type' => 'initials',
|
|
|
|
'type' => 'initials',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -219,7 +228,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Avatar',
|
|
|
|
'name' => ['Avatar', field_index].compact.join(' '),
|
|
|
|
'type' => 'image',
|
|
|
|
'type' => 'image',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -237,7 +246,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Attachment',
|
|
|
|
'name' => ['Attachment', field_index].compact.join(' '),
|
|
|
|
'type' => 'file',
|
|
|
|
'type' => 'file',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -255,7 +264,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Stamp',
|
|
|
|
'name' => ['Stamp', field_index].compact.join(' '),
|
|
|
|
'type' => 'stamp',
|
|
|
|
'type' => 'stamp',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'readonly' => true,
|
|
|
|
'readonly' => true,
|
|
|
|
@ -274,7 +283,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Cell code',
|
|
|
|
'name' => ['Cell code', field_index].compact.join(' '),
|
|
|
|
'type' => 'cells',
|
|
|
|
'type' => 'cells',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -293,7 +302,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Payment',
|
|
|
|
'name' => ['Payment', field_index].compact.join(' '),
|
|
|
|
'type' => 'payment',
|
|
|
|
'type' => 'payment',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => { 'currency' => 'EUR', 'price' => 1000 },
|
|
|
|
'preferences' => { 'currency' => 'EUR', 'price' => 1000 },
|
|
|
|
@ -311,7 +320,7 @@ FactoryBot.define do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'uuid' => SecureRandom.uuid,
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'submitter_uuid' => submitter['uuid'],
|
|
|
|
'name' => 'Mobile Phone',
|
|
|
|
'name' => ['Mobile Phone', field_index].compact.join(' '),
|
|
|
|
'type' => 'phone',
|
|
|
|
'type' => 'phone',
|
|
|
|
'required' => true,
|
|
|
|
'required' => true,
|
|
|
|
'preferences' => {},
|
|
|
|
'preferences' => {},
|
|
|
|
@ -330,6 +339,7 @@ FactoryBot.define do
|
|
|
|
|
|
|
|
|
|
|
|
fields
|
|
|
|
fields
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
template.save!
|
|
|
|
template.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|