debian-mirror-gitlab/spec/finders/ci/pipeline_schedules_finder_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Ci::PipelineSchedulesFinder do
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
let!(:active_schedule) { create(:ci_pipeline_schedule, project: project) }
let!(:inactive_schedule) { create(:ci_pipeline_schedule, :inactive, project: project) }
2021-02-22 17:27:13 +05:30
subject { described_class.new(project).execute(**params) }
2017-08-17 22:00:37 +05:30
describe "#execute" do
context 'when the scope is nil' do
let(:params) { { scope: nil } }
2019-02-15 15:39:39 +05:30
it 'selects all pipeline schedules' do
2023-04-23 21:23:45 +05:30
expect(subject).to contain_exactly(active_schedule, inactive_schedule)
end
end
context 'when the id is nil' do
let(:params) { { ids: nil } }
it 'selects all pipeline schedules' do
expect(subject).to contain_exactly(active_schedule, inactive_schedule)
end
end
context 'when the id is a single pipeline schedule' do
let(:params) { { ids: active_schedule.id } }
it 'selects one pipeline schedule' do
expect(subject).to contain_exactly(active_schedule)
end
end
context 'when multiple ids are provided' do
let(:params) { { ids: [active_schedule.id, inactive_schedule.id] } }
it 'selects multiple pipeline schedules' do
expect(subject).to contain_exactly(active_schedule, inactive_schedule)
end
end
context 'when multiple ids are provided and a scope is set' do
let(:params) { { scope: 'active', ids: [active_schedule.id, inactive_schedule.id] } }
it 'selects one pipeline schedule' do
expect(subject).to contain_exactly(active_schedule)
2017-08-17 22:00:37 +05:30
end
end
context 'when the scope is active' do
let(:params) { { scope: 'active' } }
it 'selects only active pipelines' do
2023-04-23 21:23:45 +05:30
expect(subject).to contain_exactly(active_schedule)
2017-08-17 22:00:37 +05:30
end
end
context 'when the scope is inactve' do
let(:params) { { scope: 'inactive' } }
it 'selects only inactive pipelines' do
2023-04-23 21:23:45 +05:30
expect(subject).to contain_exactly(inactive_schedule)
2017-08-17 22:00:37 +05:30
end
end
end
end