summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-11-01 17:19:12 +0900
committerShinya Maeda <shinya@gitlab.com>2018-11-02 10:17:47 +0900
commitae75fe7461ac72f621498797f478d42331342b84 (patch)
tree87c2e75fe8ef78493f3d30048bd885c515232051
parent380fee7494d06407dccc292c3cbedbcee7b6e235 (diff)
downloadgitlab-ce-ae75fe7461ac72f621498797f478d42331342b84.tar.gz
Fix weird virtual deployment status
-rw-r--r--app/models/ci/build.rb12
-rw-r--r--spec/models/ci/build_spec.rb34
2 files changed, 19 insertions, 27 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 15130308e10..b207b427c1e 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -723,7 +723,7 @@ module Ci
if success?
return successful_deployment_status
- elsif complete? && !success?
+ elsif failed?
return :failed
end
@@ -740,13 +740,11 @@ module Ci
end
def successful_deployment_status
- if success? && deployment&.last?
- return :last
- elsif success? && deployment.present?
- return :out_of_date
+ if deployment&.last?
+ :last
+ else
+ :out_of_date
end
-
- :creating
end
def each_report(report_types)
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 1be1602fe36..5fa3059e55f 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -813,33 +813,27 @@ describe Ci::Build do
describe '.deployment' do
subject { build.deployment }
- context 'when there is an old deployment record' do
- before do
- create(:deployment, deployable: build, project: project)
- end
-
- context 'when there is a deployment record with created status' do
- let!(:deployment) { create(:deployment, deployable: build, project: project) }
+ context 'when there is a deployment record with created status' do
+ let!(:deployment) { create(:deployment, deployable: build, project: project) }
- it 'returns the record' do
- is_expected.to eq(deployment)
- end
+ it 'returns the record' do
+ is_expected.to eq(deployment)
end
+ end
- context 'when there is a deployment record with running status' do
- let!(:deployment) { create(:deployment, :running, deployable: build, project: project) }
+ context 'when there is a deployment record with running status' do
+ let!(:deployment) { create(:deployment, :running, deployable: build, project: project) }
- it 'returns the record' do
- is_expected.to eq(deployment)
- end
+ it 'returns the record' do
+ is_expected.to eq(deployment)
end
+ end
- context 'when there is a deployment record with success status' do
- let!(:deployment) { create(:deployment, :success, deployable: build, project: project) }
+ context 'when there is a deployment record with success status' do
+ let!(:deployment) { create(:deployment, :success, deployable: build, project: project) }
- it 'returns the record' do
- is_expected.to eq(deployment)
- end
+ it 'returns the record' do
+ is_expected.to eq(deployment)
end
end
end