From b65fcc320d65367973a58a01618914056993541b Mon Sep 17 00:00:00 2001 From: James Ramsay Date: Sun, 1 Apr 2018 17:16:35 -0400 Subject: Add sha filter to list pipelines To find the pipeline for a specific sha requires scanning the list of all pipelines for a ref that contains the sha. This makes it hard to find the pipeline id needed to access a trace for a specific job run in the pipeline using the API. --- spec/finders/pipelines_finder_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'spec') diff --git a/spec/finders/pipelines_finder_spec.rb b/spec/finders/pipelines_finder_spec.rb index 2b19cda35b0..d6253b605b9 100644 --- a/spec/finders/pipelines_finder_spec.rb +++ b/spec/finders/pipelines_finder_spec.rb @@ -203,5 +203,25 @@ describe PipelinesFinder do end end end + + context 'when sha is specified' do + let!(:pipeline) { create(:ci_pipeline, project: project, sha: '97de212e80737a608d939f648d959671fb0a0142') } + + context 'when sha exists' do + let(:params) { { sha: '97de212e80737a608d939f648d959671fb0a0142' } } + + it 'returns matched pipelines' do + is_expected.to eq([pipeline]) + end + end + + context 'when sha does not exist' do + let(:params) { { sha: 'invalid-sha' } } + + it 'returns empty' do + is_expected.to be_empty + end + end + end end end -- cgit v1.2.3