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 @@ ...@@ -4,6 +4,8 @@
class PagesDeployment < ApplicationRecord class PagesDeployment < ApplicationRecord
include FileStoreMounter include FileStoreMounter
attribute :file_store, :integer, default: -> { ::Pages::DeploymentUploader.default_store }
belongs_to :project, optional: false belongs_to :project, optional: false
belongs_to :ci_build, class_name: 'Ci::Build', optional: true belongs_to :ci_build, class_name: 'Ci::Build', optional: true
...@@ -17,8 +19,6 @@ class PagesDeployment < ApplicationRecord ...@@ -17,8 +19,6 @@ class PagesDeployment < ApplicationRecord
before_validation :set_size, if: :file_changed? before_validation :set_size, if: :file_changed?
default_value_for(:file_store) { ::Pages::DeploymentUploader.default_store }
mount_file_store_uploader ::Pages::DeploymentUploader mount_file_store_uploader ::Pages::DeploymentUploader
def log_geo_deleted_event def log_geo_deleted_event
......
...@@ -5,7 +5,7 @@ FactoryBot.define do ...@@ -5,7 +5,7 @@ FactoryBot.define do
project project
after(:build) do |deployment, _evaluator| 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 = fixture_file_upload(filepath)
deployment.file_sha256 = Digest::SHA256.file(filepath).hexdigest deployment.file_sha256 = Digest::SHA256.file(filepath).hexdigest
......
...@@ -27,14 +27,26 @@ RSpec.describe PagesDeployment do ...@@ -27,14 +27,26 @@ RSpec.describe PagesDeployment do
end end
describe 'default for file_store' do 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 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 end
it 'uses remote store when object storage is enabled' do it 'uses remote store when object storage is enabled' do
stub_pages_object_storage(::Pages::DeploymentUploader) 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
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