Commit d2084e45 authored by Pavel Shutsin's avatar Pavel Shutsin

Fix beta feature check

Beta feature should be available regardless of license rules
when enabled for specific group, and should respect
license rules when enabled globally
parent f6c40a9e
...@@ -111,8 +111,7 @@ module EE ...@@ -111,8 +111,7 @@ module EE
# it. This is the case when we're ready to enable a feature for anyone # it. This is the case when we're ready to enable a feature for anyone
# with the correct license. # with the correct license.
def beta_feature_available?(feature) def beta_feature_available?(feature)
::Feature.enabled?(feature, self) || ::Feature.enabled?(feature) ? feature_available?(feature) : ::Feature.enabled?(feature, self)
(::Feature.enabled?(feature) && feature_available?(feature))
end end
alias_method :alpha_feature_available?, :beta_feature_available? alias_method :alpha_feature_available?, :beta_feature_available?
......
...@@ -303,8 +303,7 @@ module EE ...@@ -303,8 +303,7 @@ module EE
# it. This is the case when we're ready to enable a feature for anyone # it. This is the case when we're ready to enable a feature for anyone
# with the correct license. # with the correct license.
def beta_feature_available?(feature) def beta_feature_available?(feature)
::Feature.enabled?(feature, self) || ::Feature.enabled?(feature) ? feature_available?(feature) : ::Feature.enabled?(feature, self)
(::Feature.enabled?(feature) && feature_available?(feature))
end end
alias_method :alpha_feature_available?, :beta_feature_available? alias_method :alpha_feature_available?, :beta_feature_available?
......
...@@ -12,28 +12,28 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do ...@@ -12,28 +12,28 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do
stub_licensed_features(insights: false) stub_licensed_features(insights: false)
end end
context 'when the feature flag is disabled globally' do context 'when the feature flag is enabled globally' do
before do before do
stub_feature_flags(insights: false) stub_feature_flags(insights: true)
end end
it { expect(entity.public_send(method_name, :insights)).to be_falsy } it { expect(entity.public_send(method_name, :insights)).to be_falsy }
end end
context 'when the feature flag is enabled globally' do context 'when the feature flag is disabled globally' do
before do before do
stub_feature_flags(insights: true) stub_feature_flags(insights: false)
end end
it { expect(entity.public_send(method_name, :insights)).to be_truthy } it { expect(entity.public_send(method_name, :insights)).to be_falsy }
end
context 'when the feature flag is enabled for the entity' do context 'and enabled for the entity' do
before do before do
stub_feature_flags(insights: { enabled: true, thing: entity }) stub_feature_flags(insights: { enabled: true, thing: entity })
end end
it { expect(entity.public_send(method_name, :insights)).to be_truthy } it { expect(entity.public_send(method_name, :insights)).to be_truthy }
end
end end
end end
...@@ -42,14 +42,6 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do ...@@ -42,14 +42,6 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do
stub_licensed_features(insights: true) stub_licensed_features(insights: true)
end end
context 'when the feature flag is disabled globally' do
before do
stub_feature_flags(insights: false)
end
it { expect(entity.public_send(method_name, :insights)).to be_falsy }
end
context 'when the feature flag is enabled globally' do context 'when the feature flag is enabled globally' do
before do before do
stub_feature_flags(insights: true) stub_feature_flags(insights: true)
...@@ -58,12 +50,20 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do ...@@ -58,12 +50,20 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do
it { expect(entity.public_send(method_name, :insights)).to be_truthy } it { expect(entity.public_send(method_name, :insights)).to be_truthy }
end end
context 'when the feature flag is enabled for the entity' do context 'when the feature flag is disabled globally' do
before do before do
stub_feature_flags(insights: { enabled: true, thing: entity }) stub_feature_flags(insights: false)
end end
it { expect(entity.public_send(method_name, :insights)).to be_truthy } it { expect(entity.public_send(method_name, :insights)).to be_falsy }
context 'and enabled for the entity' do
before do
stub_feature_flags(insights: { enabled: true, thing: entity })
end
it { expect(entity.public_send(method_name, :insights)).to be_truthy }
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment