2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
|
|
|
factory :pages_deployment, class: 'PagesDeployment' do
|
|
|
|
project
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
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)
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
deployment.file = file
|
|
|
|
deployment.file_sha256 = Digest::SHA256.file(file.path).hexdigest
|
|
|
|
::Zip::File.open(file.path) do |zip_archive|
|
2021-01-29 00:20:46 +05:30
|
|
|
deployment.file_count = zip_archive.count
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|