summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/ci/build/eraseable.rb10
-rw-r--r--features/steps/project/builds/summary.rb2
-rw-r--r--spec/models/ci/build/eraseable_spec.rb17
3 files changed, 23 insertions, 6 deletions
diff --git a/app/models/ci/build/eraseable.rb b/app/models/ci/build/eraseable.rb
index 08f5d82fc5d..9d3d0627b45 100644
--- a/app/models/ci/build/eraseable.rb
+++ b/app/models/ci/build/eraseable.rb
@@ -26,16 +26,18 @@ module Ci
end
end
+ def erased?
+ !self.erased_at.nil?
+ end
+
private
def erase_trace!
- File.truncate(path_to_trace, 0) if File.file?(path_to_trace)
+ self.trace = nil
end
def update_erased!(user = nil)
- self.erased_by = user if user
- self.erased_at = Time.now
- self.save!
+ self.update(erased_by: user, erased_at: Time.now)
end
end
end
diff --git a/features/steps/project/builds/summary.rb b/features/steps/project/builds/summary.rb
index 1bcff659181..fd20a317850 100644
--- a/features/steps/project/builds/summary.rb
+++ b/features/steps/project/builds/summary.rb
@@ -18,7 +18,7 @@ class Spinach::Features::ProjectBuildsSummary < Spinach::FeatureSteps
step 'recent build has been erased' do
expect(@build.artifacts_file.exists?).to be_falsy
expect(@build.artifacts_metadata.exists?).to be_falsy
- expect(File.zero?(@build.path_to_trace)).to be true
+ expect(@build.trace).to be_empty
end
step 'recent build summary does not have artifacts widget' do
diff --git a/spec/models/ci/build/eraseable_spec.rb b/spec/models/ci/build/eraseable_spec.rb
index fcb82de254f..9e5099ce796 100644
--- a/spec/models/ci/build/eraseable_spec.rb
+++ b/spec/models/ci/build/eraseable_spec.rb
@@ -11,7 +11,7 @@ describe Ci::Build::Eraseable, models: true do
end
it 'should erase build trace in trace file' do
- expect(File.zero?(build.path_to_trace)).to eq true
+ expect(build.trace).to be_empty
end
it 'should set erased to true' do
@@ -78,6 +78,21 @@ describe Ci::Build::Eraseable, models: true do
it { is_expected.to be_truthy }
end
+ describe '#erased?' do
+ let!(:build) { create(:ci_build_with_trace, :success, :artifacts) }
+ subject { build.erased? }
+
+ context 'build has not been erased' do
+ it { is_expected.to be false }
+ end
+
+ context 'build has been erased' do
+ before { build.erase! }
+
+ it { is_expected.to be true }
+ end
+ end
+
context 'metadata and build trace are not available' do
let!(:build) { create(:ci_build, :success, :artifacts) }
before { build.remove_artifacts_metadata! }