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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/ci/job_artifact_spec.rb')
-rw-r--r--spec/models/ci/job_artifact_spec.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb
index a94a1dd284a..d63f87e8943 100644
--- a/spec/models/ci/job_artifact_spec.rb
+++ b/spec/models/ci/job_artifact_spec.rb
@@ -351,6 +351,21 @@ RSpec.describe Ci::JobArtifact do
end
end
+ context 'when updating any field except the file' do
+ let(:artifact) { create(:ci_job_artifact, :unarchived_trace_artifact, file_store: 2) }
+
+ before do
+ stub_artifacts_object_storage(direct_upload: true)
+ artifact.file.object_store = 1
+ end
+
+ it 'the `after_commit` hook does not update `file_store`' do
+ artifact.update!(expire_at: Time.current)
+
+ expect(artifact.file_store).to be(2)
+ end
+ end
+
describe 'validates file format' do
subject { artifact }
@@ -507,6 +522,53 @@ RSpec.describe Ci::JobArtifact do
end
end
+ describe '#store_after_commit?' do
+ let(:file_type) { :archive }
+ let(:artifact) { build(:ci_job_artifact, file_type) }
+
+ context 'when direct upload is enabled' do
+ before do
+ stub_artifacts_object_storage(direct_upload: true)
+ end
+
+ context 'when the artifact is a trace' do
+ let(:file_type) { :trace }
+
+ context 'when ci_store_trace_outside_transaction is enabled' do
+ it 'returns true' do
+ expect(artifact.store_after_commit?).to be_truthy
+ end
+ end
+
+ context 'when ci_store_trace_outside_transaction is disabled' do
+ before do
+ stub_feature_flags(ci_store_trace_outside_transaction: false)
+ end
+
+ it 'returns false' do
+ expect(artifact.store_after_commit?).to be_falsey
+ end
+ end
+ end
+
+ context 'when the artifact is not a trace' do
+ it 'returns false' do
+ expect(artifact.store_after_commit?).to be_falsey
+ end
+ end
+ end
+
+ context 'when direct upload is disabled' do
+ before do
+ stub_artifacts_object_storage(direct_upload: false)
+ end
+
+ it 'returns false' do
+ expect(artifact.store_after_commit?).to be_falsey
+ end
+ end
+ end
+
describe 'file is being stored' do
subject { create(:ci_job_artifact, :archive) }