Commit f3e92fb4 authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Grzegorz Bizon

Make CI build eraseable only if build is completed

parent c8102d93
......@@ -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)
......
......@@ -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
......
......@@ -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
......
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