93 lines
2.7 KiB
Ruby
93 lines
2.7 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 :non_native do
|
|
contract do
|
|
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
|
|
Rack::Test::UploadedFile.new(path, "application/pdf")
|
|
end
|
|
end
|
|
|
|
trait :full_native do
|
|
address_street1 'Dummy St.'
|
|
address_city 'Dummy City'
|
|
address_state 'Dummy State'
|
|
address_zip '12121'
|
|
address_country 'US'
|
|
person_first_name 'John'
|
|
person_last_name 'Doe'
|
|
person_phone '222223333'
|
|
person_email 'mail@mail.com'
|
|
person_company 'Dummy Company Inc.'
|
|
person_title 'mr.'
|
|
person_address_street1 'Dummy St. 2'
|
|
person_address_city 'Dummy City 2'
|
|
person_address_state 'Dummy State 2'
|
|
person_address_zip '1111111'
|
|
person_address_country 'US'
|
|
filming_ended_on DateTime.now
|
|
filming_started_on '01/02/20'
|
|
filming_hours '04-20'
|
|
end
|
|
|
|
factory :empty_location_release do
|
|
name nil
|
|
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
|