blob: ed973071a6df9660b1ecaab574bf5c4a08aa3958 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe StubSaasFeatures, feature_category: :shared do
describe '#stub_saas_features' do
using RSpec::Parameterized::TableSyntax
let(:feature_name) { '_some_saas_feature_' }
context 'when checking global state' do
where(:feature_value) do
[true, false]
end
with_them do
before do
stub_saas_features(feature_name => feature_value)
end
it { expect(::Gitlab::Saas.feature_available?(feature_name)).to eq(feature_value) }
end
end
context 'when value is not boolean' do
it 'raises an error' do
expect do
stub_saas_features(feature_name => '_not_boolean_')
end.to raise_error(ArgumentError, /value must be boolean/)
end
end
it 'subsequent run changes state' do
# enable FF on all
stub_saas_features({ feature_name => true })
expect(::Gitlab::Saas.feature_available?(feature_name)).to eq(true)
# disable FF on all
stub_saas_features({ feature_name => false })
expect(::Gitlab::Saas.feature_available?(feature_name)).to eq(false)
end
it 'handles multiple features' do
stub_saas_features(feature_name => false, '_some_new_feature_' => true)
expect(::Gitlab::Saas.feature_available?(feature_name)).to eq(false)
expect(::Gitlab::Saas.feature_available?('_some_new_feature_')).to eq(true)
end
end
end
|