1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/factories/passports.rb

34 lines
948 B
Ruby
Raw Normal View History

2018-11-29 20:19:38 -05:00
# frozen_string_literal: true
FactoryBot.define do
factory :passport do
2018-11-29 22:41:57 -05:00
transient do
image_filename { image_fixture }
image_fixture { "passport_image_#{rand(1..4)}.jpg" }
2018-11-29 23:40:50 -05:00
image_path { Rails.root.join 'fixtures', image_fixture }
2018-11-29 22:41:57 -05:00
end
2018-11-29 20:19:38 -05:00
surname { Faker::Name.last_name }
given_name { Faker::Name.first_name }
patronymic { Faker::Name.first_name }
2018-11-29 23:31:08 -05:00
sex { Passport.sexes.keys.sample }
2018-11-29 20:19:38 -05:00
date_of_birth { Faker::Date.backward }
place_of_birth { Faker::Address.city }
series { rand 0..9999 }
number { rand 0..999_999 }
issued_by { Faker::Lorem.sentence }
unit_code do
"#{rand(0..999).to_s.rjust(3, '0')}-#{rand(0..999).to_s.rjust(3, '0')}"
end
date_of_issue { Faker::Date.backward }
2018-11-29 22:41:57 -05:00
2018-11-30 00:49:51 -05:00
after :build do |passport, evaluator|
2018-11-29 22:41:57 -05:00
passport.image.attach(
filename: evaluator.image_filename,
io: File.open(evaluator.image_path),
)
end
2018-11-29 20:19:38 -05:00
end
end