2020-09-17 17:09:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
|
|
|
factory :pages_deployment, class: 'PagesDeployment' do
|
|
|
|
project
|
|
|
|
|
2021-02-10 07:09:45 -05:00
|
|
|
transient do
|
|
|
|
filename { nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait(:migrated) do
|
|
|
|
filename { PagesDeployment::MIGRATED_FILE_NAME }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |deployment, evaluator|
|
|
|
|
file = UploadedFile.new("spec/fixtures/pages.zip", filename: evaluator.filename)
|
2020-10-22 11:08:25 -04:00
|
|
|
|
2021-02-10 07:09:45 -05:00
|
|
|
deployment.file = file
|
|
|
|
deployment.file_sha256 = Digest::SHA256.file(file.path).hexdigest
|
|
|
|
::Zip::File.open(file.path) do |zip_archive|
|
2020-10-22 11:08:25 -04:00
|
|
|
deployment.file_count = zip_archive.count
|
|
|
|
end
|
2020-09-24 14:09:51 -04:00
|
|
|
end
|
2020-09-17 17:09:39 -04:00
|
|
|
end
|
|
|
|
end
|