Make CI build eraseable only if build is completed

This commit is contained in:
Grzegorz Bizon 2016-02-01 13:46:02 +01:00 committed by Grzegorz Bizon
parent c8102d938b
commit f3e92fb4d0
3 changed files with 7 additions and 3 deletions

View file

@ -205,6 +205,10 @@ module Ci
end
end
def trace_empty?
raw_trace.blank?
end
def raw_trace
if File.file?(path_to_trace)
File.read(path_to_trace)

View file

@ -11,7 +11,7 @@ module Ci
end
def eraseable?
artifacts_file.exists? || File.file?(path_to_trace)
complete? && (artifacts_file.exists? || !trace_empty?)
end
def erase_url

View file

@ -20,7 +20,7 @@ describe Ci::Build::Eraseable, models: true do
end
context 'build is eraseable' do
let!(:build) { create(:ci_build_with_trace, :artifacts) }
let!(:build) { create(:ci_build_with_trace, :success, :artifacts) }
describe '#erase!' do
before { build.erase! }
@ -49,7 +49,7 @@ describe Ci::Build::Eraseable, models: true do
end
context 'metadata and build trace are not available' do
let!(:build) { create(:ci_build, :artifacts) }
let!(:build) { create(:ci_build, :success, :artifacts) }
before { build.remove_artifacts_metadata! }
describe '#erase!' do