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
30f019dca7/app/views/projects/jobs/show.html.haml (L28)
This commit is contained in:
Steve Azzopardi 2018-10-15 08:26:01 +02:00
parent fbec87b4b5
commit 5d11f55f76
No known key found for this signature in database
GPG Key ID: 605BD4706E7DB47D
2 changed files with 26 additions and 1 deletions

View File

@ -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

View File

@ -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)