diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
commit | 419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch) | |
tree | 1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /spec/support_specs/helpers/stub_saas_features_spec.rb | |
parent | 1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff) |
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'spec/support_specs/helpers/stub_saas_features_spec.rb')
-rw-r--r-- | spec/support_specs/helpers/stub_saas_features_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/support_specs/helpers/stub_saas_features_spec.rb b/spec/support_specs/helpers/stub_saas_features_spec.rb new file mode 100644 index 00000000000..ed973071a6d --- /dev/null +++ b/spec/support_specs/helpers/stub_saas_features_spec.rb @@ -0,0 +1,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 |