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.rb31
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb
index a1fd51f60ea..e94445f17cd 100644
--- a/spec/models/ci/job_artifact_spec.rb
+++ b/spec/models/ci/job_artifact_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Ci::JobArtifact do
+RSpec.describe Ci::JobArtifact, feature_category: :build_artifacts do
let(:artifact) { create(:ci_job_artifact, :archive) }
describe "Associations" do
@@ -27,6 +27,29 @@ RSpec.describe Ci::JobArtifact do
subject { build(:ci_job_artifact, :archive, job: job, size: 107464) }
end
+ describe 'after_create_commit callback' do
+ it 'logs the job artifact create' do
+ artifact = build(:ci_job_artifact, file_type: 3, size: 8888, file_format: 2, locked: 1)
+
+ expect(Gitlab::Ci::Artifacts::Logger).to receive(:log_created) do |record|
+ expect(record.size).to eq(artifact.size)
+ expect(record.file_type).to eq(artifact.file_type)
+ expect(record.file_format).to eq(artifact.file_format)
+ expect(record.locked).to eq(artifact.locked)
+ end
+
+ artifact.save!
+ end
+ end
+
+ describe 'after_destroy_commit callback' do
+ it 'logs the job artifact destroy' do
+ expect(Gitlab::Ci::Artifacts::Logger).to receive(:log_deleted).with(artifact, :log_destroy)
+
+ artifact.destroy!
+ end
+ end
+
describe '.not_expired' do
it 'returns artifacts that have not expired' do
_expired_artifact = create(:ci_job_artifact, :expired)
@@ -770,4 +793,10 @@ RSpec.describe Ci::JobArtifact do
end
end
end
+
+ describe '#filename' do
+ subject { artifact.filename }
+
+ it { is_expected.to eq(artifact.file.filename) }
+ end
end