diff options
author | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-08-29 18:02:08 +0200 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-09-07 15:38:03 +0200 |
commit | 3152477114ed95d2ca5b5a27487c4f392f7486fa (patch) | |
tree | 76f12a95dbb8b25a4a8e37d1e3ee17880329b3fc /spec | |
parent | a83c5ff48f74c718bd4d0f9b5746502e2ebaff27 (diff) | |
download | gitlab-ce-3152477114ed95d2ca5b5a27487c4f392f7486fa.tar.gz |
Use PipelinesFinder in Pipelines API
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/pipelines_finder_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/finders/pipelines_finder_spec.rb b/spec/finders/pipelines_finder_spec.rb new file mode 100644 index 00000000000..7100266ab55 --- /dev/null +++ b/spec/finders/pipelines_finder_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +describe PipelinesFinder do + let(:project) { create(:project) } + + let!(:tag_pipeline) { create(:ci_pipeline, project: project, ref: 'v1.0.0') } + let!(:branch_pipeline) { create(:ci_pipeline, project: project) } + + subject { described_class.new(project).execute(params) } + + describe "#execute" do + context 'when a scope is passed' do + context 'when scope is nil' do + let(:params) { { scope: nil } } + + it 'selects all pipelines' do + expect(subject.count).to be 2 + expect(subject).to include tag_pipeline + expect(subject).to include branch_pipeline + end + end + + context 'when selecting branches' do + let(:params) { { scope: 'branches' } } + + it 'excludes tags' do + expect(subject).not_to include tag_pipeline + expect(subject).to include branch_pipeline + end + end + + context 'when selecting tags' do + let(:params) { { scope: 'tags' } } + + it 'excludes branches' do + expect(subject).to include tag_pipeline + expect(subject).not_to include branch_pipeline + end + end + end + + # Scoping to running will speed up the test as it doesn't hit the FS + let(:params) { { scope: 'running' } } + + it 'orders in descending order on ID' do + create(:ci_pipeline, project: project, ref: 'feature') + + expect(subject.map(&:id)).to eq [3, 2, 1] + end + end +end |