Commit 412a3857 authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Filipa Lacerda

Do not serialize a deployment commit showing a job

parent 1052f64c
......@@ -13,7 +13,11 @@ class BuildDetailsEntity < JobEntity
expose :deployment_status, if: -> (*) { build.starts_environment? } do
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
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', '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 include('commit')
end
end
......
......@@ -122,5 +122,29 @@ describe BuildDetailsEntity do
it { is_expected.to include(failure_reason: 'unmet_prerequisites') }
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
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