Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pages_deployments.rb « factories « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d3e2fefb4aef029aa2491b4b094d09e282e57670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

FactoryBot.define do
  factory :pages_deployment, class: 'PagesDeployment' do
    project

    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)

      deployment.file = file
      deployment.file_sha256 = Digest::SHA256.file(file.path).hexdigest
      ::Zip::File.open(file.path) do |zip_archive|
        deployment.file_count = zip_archive.count
      end
    end
  end
end