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