blob: fdcec0e96af92697d326bf1760e7ce142820065f (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineVariable do
subject { build(:ci_pipeline_variable) }
it_behaves_like "CI variable"
it { is_expected.to validate_presence_of(:key) }
describe '#hook_attrs' do
let(:variable) { create(:ci_pipeline_variable, key: 'foo', value: 'bar') }
subject { variable.hook_attrs }
it { is_expected.to be_a(Hash) }
it { is_expected.to eq({ key: 'foo', value: 'bar' }) }
end
describe 'partitioning' do
context 'with pipeline' do
let(:pipeline) { build(:ci_pipeline, partition_id: 123) }
let(:variable) { build(:ci_pipeline_variable, pipeline: pipeline, partition_id: nil) }
it 'copies the partition_id from pipeline' do
expect { variable.valid? }.to change(variable, :partition_id).from(nil).to(123)
end
end
context 'without pipeline' do
subject(:variable) { build(:ci_pipeline_variable, pipeline: nil, partition_id: nil) }
it { is_expected.to validate_presence_of(:partition_id) }
it 'does not change the partition_id value' do
expect { variable.valid? }.not_to change(variable, :partition_id)
end
end
end
end
|