blob: 4699592b6d4a6c6990aed301f4399ab6ee1b028b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineSchedulesFinder do
let(:project) { create(:project) }
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 } }
it 'selects all pipeline schedules' do
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)
end
end
context 'when the scope is active' do
let(:params) { { scope: 'active' } }
it 'selects only active pipelines' do
expect(subject).to contain_exactly(active_schedule)
end
end
context 'when the scope is inactve' do
let(:params) { { scope: 'inactive' } }
it 'selects only inactive pipelines' do
expect(subject).to contain_exactly(inactive_schedule)
end
end
end
end
|