2019-10-16 09:07:51 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-07 22:35:56 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PipelineSchedulesFinder do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2017-05-07 22:35:56 +00:00
|
|
|
|
|
|
|
let!(:active_schedule) { create(:ci_pipeline_schedule, project: project) }
|
|
|
|
let!(:inactive_schedule) { create(:ci_pipeline_schedule, :inactive, project: project) }
|
|
|
|
|
|
|
|
subject { described_class.new(project).execute(params) }
|
|
|
|
|
|
|
|
describe "#execute" do
|
|
|
|
context 'when the scope is nil' do
|
|
|
|
let(:params) { { scope: nil } }
|
|
|
|
|
2018-11-19 14:08:23 +00:00
|
|
|
it 'selects all pipeline schedules' do
|
2017-05-07 22:35:56 +00:00
|
|
|
expect(subject.count).to be(2)
|
|
|
|
expect(subject).to include(active_schedule, inactive_schedule)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the scope is active' do
|
|
|
|
let(:params) { { scope: 'active' } }
|
|
|
|
|
|
|
|
it 'selects only active pipelines' do
|
|
|
|
expect(subject.count).to be(1)
|
|
|
|
expect(subject).to include(active_schedule)
|
|
|
|
expect(subject).not_to include(inactive_schedule)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the scope is inactve' do
|
|
|
|
let(:params) { { scope: 'inactive' } }
|
|
|
|
|
|
|
|
it 'selects only inactive pipelines' do
|
|
|
|
expect(subject.count).to be(1)
|
|
|
|
expect(subject).not_to include(active_schedule)
|
|
|
|
expect(subject).to include(inactive_schedule)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|