From 7b06acea1c13b7fa9067902faaed73c7210f4bb3 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 1 Jul 2016 00:00:35 +0800 Subject: [PATCH] Use nil for non-existing files rather than 0 --- app/models/ci/build.rb | 4 +++- spec/requests/ci/api/builds_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 2079d5a2178..850895845f4 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -382,7 +382,9 @@ module Ci private def update_artifacts_size - self.artifacts_size = artifacts_file.size + self.artifacts_size = if artifacts_file.exists? + artifacts_file.size + end end def erase_trace! diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index 64cb7dd12d0..666fdbdd2b5 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -486,7 +486,7 @@ describe Ci::API::API do expect(response).to have_http_status(200) expect(build.artifacts_file.exists?).to be_falsy expect(build.artifacts_metadata.exists?).to be_falsy - expect(build.artifacts_size).to eq(0) + expect(build.artifacts_size).to be_nil end end