blob: db8ac605d7262a0af26c31d7c0fe865fe67e7eb9 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Packages::BuildInfo, type: :model do
describe 'relationships' do
it { is_expected.to belong_to(:package) }
it { is_expected.to belong_to(:pipeline) }
end
context 'with some build infos' do
let_it_be(:package) { create(:package) }
let_it_be(:build_infos) { create_list(:package_build_info, 3, :with_pipeline, package: package) }
let_it_be(:build_info_with_no_pipeline) { create(:package_build_info) }
describe '.pluck_pipeline_ids' do
subject { package.build_infos.pluck_pipeline_ids.sort }
it { is_expected.to eq(build_infos.map(&:pipeline_id).sort) }
end
describe '.without_empty_pipelines' do
subject { package.build_infos.without_empty_pipelines }
it { is_expected.to contain_exactly(*build_infos) }
end
describe '.order_by_pipeline_id asc' do
subject { package.build_infos.order_by_pipeline_id(:asc) }
it { is_expected.to eq(build_infos) }
end
describe '.order_by_pipeline_id desc' do
subject { package.build_infos.order_by_pipeline_id(:desc) }
it { is_expected.to eq(build_infos.reverse) }
end
describe '.with_pipeline_id_less_than' do
subject { package.build_infos.with_pipeline_id_less_than(build_infos[1].pipeline_id) }
it { is_expected.to contain_exactly(build_infos[0]) }
end
describe '.with_pipeline_id_greater_than' do
subject { package.build_infos.with_pipeline_id_greater_than(build_infos[1].pipeline_id) }
it { is_expected.to contain_exactly(build_infos[2]) }
end
end
end
|