diff --git a/app/models/environment_status.rb b/app/models/environment_status.rb index 7078496ff52..4a128dde5cd 100644 --- a/app/models/environment_status.rb +++ b/app/models/environment_status.rb @@ -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 diff --git a/changelogs/unreleased/remove-deployment-status-hack-from-backend.yml b/changelogs/unreleased/remove-deployment-status-hack-from-backend.yml new file mode 100644 index 00000000000..2348bfab7d9 --- /dev/null +++ b/changelogs/unreleased/remove-deployment-status-hack-from-backend.yml @@ -0,0 +1,5 @@ +--- +title: Return real deployment status to frontend +merge_request: 23270 +author: +type: fixed diff --git a/spec/features/merge_request/user_sees_deployment_widget_spec.rb b/spec/features/merge_request/user_sees_deployment_widget_spec.rb index 74290c0fff9..3e40179ad9a 100644 --- a/spec/features/merge_request/user_sees_deployment_widget_spec.rb +++ b/spec/features/merge_request/user_sees_deployment_widget_spec.rb @@ -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