Commit 9384c653 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'fix-pages-deployment-default-store' into 'master'

Properly file_store default for pages deployments

See merge request gitlab-org/gitlab!47284
parents 5fa9332d 1dd276c6
......@@ -4,6 +4,8 @@
class PagesDeployment < ApplicationRecord
include FileStoreMounter
attribute :file_store, :integer, default: -> { ::Pages::DeploymentUploader.default_store }
belongs_to :project, optional: false
belongs_to :ci_build, class_name: 'Ci::Build', optional: true
......@@ -17,8 +19,6 @@ class PagesDeployment < ApplicationRecord
before_validation :set_size, if: :file_changed?
default_value_for(:file_store) { ::Pages::DeploymentUploader.default_store }
mount_file_store_uploader ::Pages::DeploymentUploader
def log_geo_deleted_event
......
......@@ -5,7 +5,7 @@ FactoryBot.define do
project
after(:build) do |deployment, _evaluator|
filepath = Rails.root.join("spec/fixtures/pages.zip")
filepath = Rails.root.join("spec/fixtures/pages.zip")
deployment.file = fixture_file_upload(filepath)
deployment.file_sha256 = Digest::SHA256.file(filepath).hexdigest
......
......@@ -27,14 +27,26 @@ RSpec.describe PagesDeployment do
end
describe 'default for file_store' do
let(:project) { create(:project) }
let(:deployment) do
filepath = Rails.root.join("spec/fixtures/pages.zip")
described_class.create!(
project: project,
file: fixture_file_upload(filepath),
file_sha256: Digest::SHA256.file(filepath).hexdigest,
file_count: 3
)
end
it 'uses local store when object storage is not enabled' do
expect(build(:pages_deployment).file_store).to eq(ObjectStorage::Store::LOCAL)
expect(deployment.file_store).to eq(ObjectStorage::Store::LOCAL)
end
it 'uses remote store when object storage is enabled' do
stub_pages_object_storage(::Pages::DeploymentUploader)
expect(build(:pages_deployment).file_store).to eq(ObjectStorage::Store::REMOTE)
expect(deployment.file_store).to eq(ObjectStorage::Store::REMOTE)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment