From 5d11f55f7672c9ac2852a354dc03e9914f0c4312 Mon Sep 17 00:00:00 2001 From: Steve Azzopardi Date: Mon, 15 Oct 2018 08:26:01 +0200 Subject: [PATCH] Send deployment_status when job starts environment The check was if the job `has_environment` which results into showing the environment information when the job stops the environment. This result into having a blank `deployment_status`. Use `starts_environment?` to be the same as the haml we have in 11.3 https://gitlab.com/gitlab-org/gitlab-ce/blob/30f019dca78bb64bcb8b355a267be006884e6d8f/app/views/projects/jobs/show.html.haml#L28 --- app/serializers/build_details_entity.rb | 2 +- spec/features/projects/jobs_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb index 3d508a9a407..8220a11f454 100644 --- a/app/serializers/build_details_entity.rb +++ b/app/serializers/build_details_entity.rb @@ -8,7 +8,7 @@ class BuildDetailsEntity < JobEntity expose :runner, using: RunnerEntity expose :pipeline, using: PipelineEntity - expose :deployment_status, if: -> (*) { build.has_environment? } do + expose :deployment_status, if: -> (*) { build.starts_environment? } do expose :deployment_status, as: :status expose :persisted_environment, as: :environment, with: EnvironmentEntity diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 6224cbffe9d..a3a301504ff 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -423,6 +423,31 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do end end + context 'when job stops environment', :js do + let(:environment) { create(:environment, name: 'production', project: project) } + let(:build) do + create( + :ci_build, + :success, + :trace_live, + environment: environment.name, + pipeline: pipeline, + options: { environment: { action: 'stop' } } + ) + end + + before do + visit project_job_path(project, build) + wait_for_requests + end + + it 'does not show environment information banner' do + expect(page).not_to have_selector('.js-environment-container') + expect(page).not_to have_selector('.environment-information') + expect(page).not_to have_text(environment.name) + end + end + describe 'environment info in job view', :js do before do visit project_job_path(project, job)