This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit e83317a9 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Merge branch 'fix-nil-deployable-exception-on-job-controller-show' into 'master'

Fix users cannot access job detail page when deployable does not exist

Closes #65216

See merge request gitlab-org/gitlab-ce!32247
...@@ -23,7 +23,7 @@ class DeploymentEntity < Grape::Entity ...@@ -23,7 +23,7 @@ class DeploymentEntity < Grape::Entity
expose :last? expose :last?
expose :deployed_by, as: :user, using: UserEntity expose :deployed_by, as: :user, using: UserEntity
expose :deployable do |deployment, opts| expose :deployable, if: -> (deployment) { deployment.deployable.present? } do |deployment, opts|
deployment.deployable.yield_self do |deployable| deployment.deployable.yield_self do |deployable|
if include_details? if include_details?
JobEntity.represent(deployable, opts) JobEntity.represent(deployable, opts)
......
---
title: Fix users cannot access job detail page when deployable does not exist
merge_request: 32247
author:
type: fixed
...@@ -609,6 +609,14 @@ ...@@ -609,6 +609,14 @@
expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}") expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
expect(find('.js-job-deployment-link')['href']).to include(second_deployment.deployable.project.path, second_deployment.deployable_id.to_s) expect(find('.js-job-deployment-link')['href']).to include(second_deployment.deployable.project.path, second_deployment.deployable_id.to_s)
end end
context 'when deployment does not have a deployable' do
let!(:second_deployment) { create(:deployment, :success, environment: environment, deployable: nil) }
it 'has an empty href' do
expect(find('.js-job-deployment-link')['href']).to be_empty
end
end
end end
context 'job failed to deploy' do context 'job failed to deploy' do
......
...@@ -36,6 +36,15 @@ ...@@ -36,6 +36,15 @@
expect(subject).to include(:deployed_at) expect(subject).to include(:deployed_at)
end end
context 'when deployable is nil' do
let(:entity) { described_class.new(deployment, request: request, deployment_details: false) }
let(:deployment) { create(:deployment, deployable: nil, project: project) }
it 'does not expose deployable entry' do
expect(subject).not_to include(:deployable)
end
end
context 'when the pipeline has another manual action' do context 'when the pipeline has another manual action' do
let(:other_build) { create(:ci_build, :manual, name: 'another deploy', pipeline: pipeline) } let(:other_build) { create(:ci_build, :manual, name: 'another deploy', pipeline: pipeline) }
let!(:other_deployment) { create(:deployment, deployable: other_build) } let!(:other_deployment) { create(:deployment, deployable: other_build) }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment