Do not serialize a deployment commit showing a job
This commit is contained in:
parent
1052f64c3c
commit
412a385702
|
@ -13,7 +13,11 @@ class BuildDetailsEntity < JobEntity
|
||||||
|
|
||||||
expose :deployment_status, if: -> (*) { build.starts_environment? } do
|
expose :deployment_status, if: -> (*) { build.starts_environment? } do
|
||||||
expose :deployment_status, as: :status
|
expose :deployment_status, as: :status
|
||||||
expose :persisted_environment, as: :environment, with: EnvironmentEntity
|
expose :persisted_environment, as: :environment do |build, options|
|
||||||
|
options.merge(except: [{ last_deployment: [:commit] }]).yield_self do |opts|
|
||||||
|
EnvironmentEntity.represent(build.persisted_environment, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :artifact, if: -> (*) { can?(current_user, :read_build, build) } do
|
expose :artifact, if: -> (*) { can?(current_user, :read_build, build) } do
|
||||||
|
|
|
@ -269,6 +269,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
|
||||||
expect(json_response.dig('deployment_status', 'status')).to eq 'creating'
|
expect(json_response.dig('deployment_status', 'status')).to eq 'creating'
|
||||||
expect(json_response.dig('deployment_status', 'environment')).not_to be_nil
|
expect(json_response.dig('deployment_status', 'environment')).not_to be_nil
|
||||||
expect(json_response.dig('deployment_status', 'environment', 'last_deployment')).not_to be_nil
|
expect(json_response.dig('deployment_status', 'environment', 'last_deployment')).not_to be_nil
|
||||||
|
expect(json_response.dig('deployment_status', 'environment', 'last_deployment'))
|
||||||
|
.not_to include('commit')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -122,5 +122,29 @@ describe BuildDetailsEntity do
|
||||||
|
|
||||||
it { is_expected.to include(failure_reason: 'unmet_prerequisites') }
|
it { is_expected.to include(failure_reason: 'unmet_prerequisites') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when a build has environment with latest deployment' do
|
||||||
|
let(:build) do
|
||||||
|
create(:ci_build, :running, environment: environment.name, pipeline: pipeline)
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:environment) do
|
||||||
|
create(:environment, project: project, name: 'staging', state: :available)
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
create(:deployment, :success, environment: environment, project: project)
|
||||||
|
|
||||||
|
allow(request).to receive(:project).and_return(project)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not serialize latest deployment commit' do
|
||||||
|
response = subject.with_indifferent_access
|
||||||
|
|
||||||
|
response.dig(:deployment_status, :environment, :last_deployment).tap do |deployment|
|
||||||
|
expect(deployment).not_to include(:commit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue