Commit c9fdeaf7 authored by Matija Čupić's avatar Matija Čupić

Use PipelineDetailsEntity for last_pipeline

parent 123f8077
......@@ -10,15 +10,7 @@ class DashboardOperationsProjectEntity < Grape::Entity
end
expose :last_pipeline, if: -> (*) { last_pipeline } do |_, options|
pipeline_entity_for(last_pipeline, options)
end
expose :upstream_pipeline, if: -> (*) { upstream_pipeline } do |_, options|
pipeline_entity_for(upstream_pipeline, options)
end
expose :downstream_pipelines, if: -> (*) { downstream_pipelines } do |_, options|
pipeline_entity_for(downstream_pipelines, options)
PipelineDetailsEntity.represent(last_pipeline, options.merge(request: new_request))
end
expose :last_deployment, if: -> (*) { last_deployment? } do |dashboard_project_object, options|
......@@ -50,18 +42,6 @@ class DashboardOperationsProjectEntity < Grape::Entity
dashboard_project.project.last_pipeline
end
def upstream_pipeline
last_pipeline&.source_pipeline&.source_pipeline
end
def downstream_pipelines
last_pipeline&.sourced_pipelines&.map(&:source_pipeline)
end
def pipeline_entity_for(objects, options)
PipelineEntity.represent(objects, options.merge(request: new_request))
end
def last_deployment?
dashboard_project.last_deployment
end
......
......@@ -33,8 +33,8 @@ describe DashboardOperationsProjectEntity do
create(:ci_sources_pipeline, pipeline: pipeline, source_job: bridge)
end
it 'has the upstream pipeline field' do
expect(subject).to include(:upstream_pipeline)
it 'has the triggered_by pipeline field' do
expect(subject[:last_pipeline]).to include(:triggered_by)
end
end
......@@ -45,8 +45,8 @@ describe DashboardOperationsProjectEntity do
create(:ci_sources_pipeline, source_job: build)
end
it 'has the downstream pipeline field' do
expect(subject).to include(:downstream_pipelines)
it 'has the triggered pipeline field' do
expect(subject[:last_pipeline]).to include(:triggered)
end
context 'when there are multiple downstream statuses' do
......@@ -55,8 +55,8 @@ describe DashboardOperationsProjectEntity do
end
it 'has the downstream pipeline field' do
expect(subject).to include(:downstream_pipelines)
expect(subject[:downstream_pipelines].count).to eq(6)
expect(subject[:last_pipeline]).to include(:triggered)
expect(subject[:last_pipeline][:triggered].count).to eq(6)
end
end
end
......@@ -71,12 +71,12 @@ describe DashboardOperationsProjectEntity do
end
it 'has the upstream pipeline field' do
expect(subject).to include(:upstream_pipeline)
expect(subject[:last_pipeline]).to include(:triggered_by)
end
it 'has the downstream pipeline field' do
expect(subject).to include(:downstream_pipelines)
expect(subject[:downstream_pipelines].count).to eq(5)
expect(subject[:last_pipeline]).to include(:triggered)
expect(subject[:last_pipeline][:triggered].count).to eq(5)
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