blob: fbec6f98e7613d5fa04adfe3dec8f33ae2a626de (
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
RSpec.shared_context Integrations::EnableSslVerification do
# This is added to the global setup, to make sure all calls to
# `Gitlab::HTTP` in the main model spec are passing the `verify:` option.
before do
allow(Gitlab::HTTP).to receive(:perform_request)
.with(anything, anything, include(verify: true))
.and_call_original
end
describe 'accessors' do
it { is_expected.to respond_to(:enable_ssl_verification) }
it { is_expected.to respond_to(:enable_ssl_verification?) }
end
describe '#initialize_properties' do
it 'enables the setting by default' do
expect(integration.enable_ssl_verification).to be(true)
end
it 'does not enable the setting if the record is already persisted' do
allow(integration).to receive(:new_record?).and_return(false)
integration.enable_ssl_verification = false
integration.send(:initialize_properties)
expect(integration.enable_ssl_verification).to be(false)
end
it 'does not enable the setting if a custom value was set' do
integration = described_class.new(enable_ssl_verification: false)
expect(integration.enable_ssl_verification).to be(false)
end
end
describe '#fields' do
it 'inserts the checkbox field after the first URL field, or at the end' do
names = integration.fields.pluck(:name)
url_index = names.index { |name| name.ends_with?('_url') }
insert_index = url_index ? url_index + 1 : names.size - 1
expect(names.index('enable_ssl_verification')).to eq insert_index
end
it 'does not insert the field repeatedly' do
expect(integration.fields.pluck(:name)).to eq(integration.fields.pluck(:name))
end
end
end
|