2019-10-16 05:07:51 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-07 18:35:56 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe Ci::PipelineSchedulesFinder do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-05-07 18:35:56 -04:00
|
|
|
|
|
|
|
let!(:active_schedule) { create(:ci_pipeline_schedule, project: project) }
|
|
|
|
let!(:inactive_schedule) { create(:ci_pipeline_schedule, :inactive, project: project) }
|
|
|
|
|
2020-11-24 04:09:32 -05:00
|
|
|
subject { described_class.new(project).execute(**params) }
|
2017-05-07 18:35:56 -04:00
|
|
|
|
|
|
|
describe "#execute" do
|
|
|
|
context 'when the scope is nil' do
|
|
|
|
let(:params) { { scope: nil } }
|
|
|
|
|
2018-11-19 09:08:23 -05:00
|
|
|
it 'selects all pipeline schedules' do
|
2017-05-07 18:35:56 -04: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
|