Merge branch 'remove-deployment-status-hack-from-backend' into 'master'

Return real deployment status to frontend

Closes #53578

See merge request gitlab-org/gitlab-ce!23270
This commit is contained in:
Rémy Coutable 2018-11-28 15:15:51 +00:00
commit 56da230826
3 changed files with 20 additions and 17 deletions

View file

@ -8,6 +8,7 @@ class EnvironmentStatus
delegate :id, to: :environment
delegate :name, to: :environment
delegate :project, to: :environment
delegate :status, to: :deployment, allow_nil: true
delegate :deployed_at, to: :deployment, allow_nil: true
def self.for_merge_request(mr, user)
@ -43,22 +44,6 @@ class EnvironmentStatus
.merge_request_diff_files.where(deleted_file: false)
end
##
# Since frontend has not supported all statuses yet, BE has to
# proxy some status to a supported status.
def status
return unless deployment
case deployment.status
when 'created'
'running'
when 'canceled'
'failed'
else
deployment.status
end
end
private
PAGE_EXTENSIONS = /\A\.(s?html?|php|asp|cgi|pl)\z/i.freeze

View file

@ -0,0 +1,5 @@
---
title: Return real deployment status to frontend
merge_request: 23270
author:
type: fixed

View file

@ -65,7 +65,20 @@ describe 'Merge request > User sees deployment widget', :js do
visit project_merge_request_path(project, merge_request)
wait_for_requests
expect(page).to have_content("Deploying to #{environment.name}")
expect(page).to have_content("Will deploy to #{environment.name}")
expect(page).not_to have_css('.js-deploy-time')
end
end
context 'when deployment was cancelled' do
let(:build) { create(:ci_build, :canceled, pipeline: pipeline) }
let!(:deployment) { create(:deployment, :canceled, environment: environment, sha: sha, ref: ref, deployable: build) }
it 'displays that the environment name' do
visit project_merge_request_path(project, merge_request)
wait_for_requests
expect(page).to have_content("Failed to deploy to #{environment.name}")
expect(page).not_to have_css('.js-deploy-time')
end
end