Commit fa838469 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'mo-use-file-store-mounter-pipeline-artifact' into 'master'

Use FileStoreMounter in PipelineArtifact

See merge request gitlab-org/gitlab!39490
parents 5508b4aa ad12e626
......@@ -6,6 +6,7 @@ module Ci
class PipelineArtifact < ApplicationRecord
extend Gitlab::Ci::Model
include Artifactable
include FileStoreMounter
FILE_STORE_SUPPORTED = [
ObjectStorage::Store::LOCAL,
......@@ -22,9 +23,8 @@ module Ci
validates :size, presence: true, numericality: { less_than_or_equal_to: FILE_SIZE_LIMIT }
validates :file_type, presence: true
mount_uploader :file, Ci::PipelineArtifactUploader
mount_file_store_uploader Ci::PipelineArtifactUploader
before_save :set_size, if: :file_changed?
after_save :update_file_store, if: :saved_change_to_file?
enum file_type: {
code_coverage: 1
......@@ -33,11 +33,5 @@ module Ci
def set_size
self.size = file.size
end
def update_file_store
# The file.object_store is set during `uploader.store!`
# which happens after object is inserted/updated
self.update_column(:file_store, file.object_store)
end
end
end
......@@ -66,10 +66,16 @@ RSpec.describe Ci::PipelineArtifact, type: :model do
subject { create(:ci_pipeline_artifact) }
context 'when existing object has local store' do
it 'is stored locally' do
expect(subject.file_store).to be(ObjectStorage::Store::LOCAL)
expect(subject.file).to be_file_storage
expect(subject.file.object_store).to eq(ObjectStorage::Store::LOCAL)
it_behaves_like 'mounted file in local store'
end
context 'when direct upload is enabled' do
before do
stub_artifacts_object_storage(Ci::PipelineArtifactUploader, direct_upload: true)
end
context 'when file is stored' do
it_behaves_like 'mounted file in object store'
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