75 lines
2.3 KiB
Ruby
75 lines
2.3 KiB
Ruby
FactoryBot.define do
|
|
factory :location_release do
|
|
association :project
|
|
|
|
name "Test Premises"
|
|
|
|
trait :native do
|
|
person_first_name "Jane"
|
|
person_last_name "Doe"
|
|
person_phone "100-555-1000"
|
|
|
|
signature do
|
|
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
|
|
Rack::Test::UploadedFile.new(path, "image/png")
|
|
end
|
|
end
|
|
|
|
trait :with_photo do
|
|
photos do
|
|
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
|
|
[Rack::Test::UploadedFile.new(path, "image/png")]
|
|
end
|
|
end
|
|
|
|
trait :amendment_signed do
|
|
amendment_signature do
|
|
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
|
|
Rack::Test::UploadedFile.new(path, "image/png")
|
|
end
|
|
amendment_signer_name "Amendment Signer"
|
|
end
|
|
|
|
trait :non_native do
|
|
contract do
|
|
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
|
|
Rack::Test::UploadedFile.new(path, "application/pdf")
|
|
end
|
|
end
|
|
|
|
factory :location_release_with_contract_template do
|
|
after(:build) do |location_release, _|
|
|
location_release.contract_template = build(:location_release_contract_template)
|
|
end
|
|
end
|
|
|
|
factory :location_release_with_contract_template_and_photo do
|
|
after(:build) do |location_release, _|
|
|
location_release.contract_template = build(:location_release_contract_template)
|
|
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
|
|
location_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
|
|
end
|
|
end
|
|
|
|
factory :location_release_with_photo do
|
|
after(:build) do |location_release, _|
|
|
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
|
|
location_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
|
|
end
|
|
end
|
|
|
|
factory :location_release_with_photos do
|
|
transient do
|
|
photos_count { 2 }
|
|
end
|
|
|
|
after(:build) do |location_release, evaluator|
|
|
location_release.photos = evaluator.photos_count.times.map do
|
|
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
|
|
Rack::Test::UploadedFile.new(path, "image/png")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|