add base feature specs
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :account do
|
||||
name { Faker::Company.name }
|
||||
locale { 'en-US' }
|
||||
timezone { 'UTC' }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :encrypted_config do
|
||||
account
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :submission do
|
||||
template
|
||||
created_by_user factory: %i[user]
|
||||
|
||||
before(:create) do |submission, _|
|
||||
submission.template_fields = submission.template.fields
|
||||
submission.template_schema = submission.template.schema
|
||||
submission.template_submitters = submission.template.submitters
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :submitter do
|
||||
submission
|
||||
email { Faker::Internet.email }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,62 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :template do
|
||||
account
|
||||
|
||||
author factory: %i[user]
|
||||
name { Faker::Book.title }
|
||||
|
||||
after(:create) do |template|
|
||||
blob = ActiveStorage::Blob.create_and_upload!(
|
||||
io: Rails.root.join('spec/fixtures/sample-document.pdf').open,
|
||||
filename: 'sample-document.pdf',
|
||||
content_type: 'application/pdf'
|
||||
)
|
||||
attachment = ActiveStorage::Attachment.create!(
|
||||
blob:,
|
||||
name: :documents,
|
||||
record: template
|
||||
)
|
||||
|
||||
Templates::ProcessDocument.call(attachment)
|
||||
|
||||
template.schema = [{ attachment_uuid: attachment.uuid, name: 'sample-document' }]
|
||||
template.submitters = [
|
||||
{
|
||||
'name' => 'First Submitter',
|
||||
'uuid' => '513848eb-1096-4abc-a743-68596b5aaa4c'
|
||||
}
|
||||
]
|
||||
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' => []
|
||||
}
|
||||
]
|
||||
|
||||
template.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :user do
|
||||
account
|
||||
first_name { Faker::Name.first_name }
|
||||
last_name { Faker::Name.last_name }
|
||||
password { 'password' }
|
||||
role { User::ADMIN_ROLE }
|
||||
email { Faker::Internet.email }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user