| ... | ... | @@ -5,6 +5,10 @@ require 'spec_helper' |
|
|
|
describe Ci::JobArtifact do
|
|
|
|
let(:artifact) { create(:ci_job_artifact, :archive) }
|
|
|
|
|
|
|
|
it_behaves_like 'UpdateProjectStatistics' do
|
|
|
|
subject { build(:ci_job_artifact, :archive, size: 106365) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "Associations" do
|
|
|
|
it { is_expected.to belong_to(:project) }
|
|
|
|
it { is_expected.to belong_to(:job) }
|
| ... | ... | @@ -102,12 +106,6 @@ describe Ci::JobArtifact do |
|
|
|
it 'sets the size from the file size' do
|
|
|
|
expect(artifact.size).to eq(106365)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates the project statistics' do
|
|
|
|
expect { artifact }
|
|
|
|
.to change { project.statistics.reload.build_artifacts_size }
|
|
|
|
.by(106365)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'updating the artifact file' do
|
| ... | ... | @@ -115,12 +113,6 @@ describe Ci::JobArtifact do |
|
|
|
artifact.update!(file: fixture_file_upload('spec/fixtures/dk.png'))
|
|
|
|
expect(artifact.size).to eq(1062)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates the project statistics' do
|
|
|
|
expect { artifact.update!(file: fixture_file_upload('spec/fixtures/dk.png')) }
|
|
|
|
.to change { artifact.project.statistics.reload.build_artifacts_size }
|
|
|
|
.by(1062 - 106365)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'validates file format' do
|
| ... | ... | @@ -259,34 +251,6 @@ describe Ci::JobArtifact do |
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when destroying the artifact' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
let!(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
|
|
|
|
|
|
|
|
it 'updates the project statistics' do
|
|
|
|
artifact = build.job_artifacts.first
|
|
|
|
|
|
|
|
expect(ProjectStatistics)
|
|
|
|
.to receive(:increment_statistic)
|
|
|
|
.and_call_original
|
|
|
|
|
|
|
|
expect { artifact.destroy }
|
|
|
|
.to change { project.statistics.reload.build_artifacts_size }
|
|
|
|
.by(-106365)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when it is destroyed from the project level' do
|
|
|
|
it 'does not update the project statistics' do
|
|
|
|
expect(ProjectStatistics)
|
|
|
|
.not_to receive(:increment_statistic)
|
|
|
|
|
|
|
|
project.update(pending_delete: true)
|
|
|
|
project.destroy!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'file is being stored' do
|
|
|
|
subject { create(:ci_job_artifact, :archive) }
|
|
|
|
|
| ... | ... | |
| ... | ... | |