diff options
author | Brett Walker <bwalker@gitlab.com> | 2018-09-04 13:34:37 -0500 |
---|---|---|
committer | Brett Walker <bwalker@gitlab.com> | 2018-09-05 09:19:16 -0500 |
commit | 3aea946e7f590319ff7b85dbbd4eedfc20569deb (patch) | |
tree | 22fd1a021eece3b982b0dfd1f8fe7cce6b5c3df8 /spec | |
parent | 589776fc2e421df12c2526f9cf8cd7f3f239a21f (diff) | |
download | gitlab-ce-3aea946e7f590319ff7b85dbbd4eedfc20569deb.tar.gz |
add 'default_enabled' to feature flags
This allows you to default a feature flag to 'on' when
checking whether it's enabled/disabled.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/feature_spec.rb | 8 | ||||
-rw-r--r-- | spec/support/helpers/stub_feature_flags.rb | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb index 8bb5a843484..48c0ba8a653 100644 --- a/spec/lib/feature_spec.rb +++ b/spec/lib/feature_spec.rb @@ -119,6 +119,10 @@ describe Feature do expect(described_class.enabled?(:some_random_feature_flag)).to be_falsey end + it 'returns true for undefined feature with default_enabled' do + expect(described_class.enabled?(:some_random_feature_flag, default_enabled: true)).to be_truthy + end + it 'returns false for existing disabled feature in the database' do described_class.disable(:disabled_feature_flag) @@ -160,6 +164,10 @@ describe Feature do expect(described_class.disabled?(:some_random_feature_flag)).to be_truthy end + it 'returns false for undefined feature with default_enabled' do + expect(described_class.disabled?(:some_random_feature_flag, default_enabled: true)).to be_falsey + end + it 'returns true for existing disabled feature in the database' do described_class.disable(:disabled_feature_flag) diff --git a/spec/support/helpers/stub_feature_flags.rb b/spec/support/helpers/stub_feature_flags.rb index c54a871b157..4061a8d1bc9 100644 --- a/spec/support/helpers/stub_feature_flags.rb +++ b/spec/support/helpers/stub_feature_flags.rb @@ -4,8 +4,8 @@ module StubFeatureFlags # @param [Hash] features where key is feature name and value is boolean whether enabled or not def stub_feature_flags(features) features.each do |feature_name, enabled| - allow(Feature).to receive(:enabled?).with(feature_name) { enabled } - allow(Feature).to receive(:enabled?).with(feature_name.to_s) { enabled } + allow(Feature).to receive(:enabled?).with(feature_name, any_args) { enabled } + allow(Feature).to receive(:enabled?).with(feature_name.to_s, any_args) { enabled } end end end |