Commit 439e154c authored by Rémy Coutable's avatar Rémy Coutable 🔴

Merge branch 'make-sure-that-artifacts-file-is-saved' into 'master'

Make sure that artifacts_file is nullified after removing artifacts

## What does this MR do?
Fixes a problem that `ExpireBuildArtifactsWorker` is executed for all previously removed artifacts.

## Why was this MR needed?
Currently the `Ci::Build::erase_artifacts!` doesn't ensure that data are saved to database.
The bang at end of this method lets you believe that it should do so.
This adds a missing `save` to this method.

## What are the relevant issue numbers?
None, yet.

## CHANGELOG
Since this is regression in feature introduce in RC4 no CHANGELOG entry is needed.

cc @grzesiek 


See merge request !4741
parents 2d622d44 d63673d6
......@@ -341,6 +341,7 @@ module Ci
def erase_artifacts!
remove_artifacts_file!
remove_artifacts_metadata!
save
end
def erase(opts = {})
......
......@@ -20,6 +20,10 @@ describe ExpireBuildArtifactsWorker do
it 'does remove files' do
expect(build.reload.artifacts_file.exists?).to be_falsey
end
it 'does nullify artifacts_file column' do
expect(build.reload.artifacts_file_identifier).to be_nil
end
end
context 'with not yet expired artifacts' do
......@@ -32,6 +36,10 @@ describe ExpireBuildArtifactsWorker do
it 'does not remove files' do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
it 'does not nullify artifacts_file column' do
expect(build.reload.artifacts_file_identifier).not_to be_nil
end
end
context 'without expire date' do
......@@ -44,6 +52,10 @@ describe ExpireBuildArtifactsWorker do
it 'does not remove files' do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
it 'does not nullify artifacts_file column' do
expect(build.reload.artifacts_file_identifier).not_to be_nil
end
end
context 'for expired artifacts' do
......
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