Files
old-holivud2/spec/factories/location_releases.rb
2020-05-31 22:38:19 +02:00

60 lines
1.8 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 :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