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
# it. This is the case when we're ready to enable a feature for anyone
# with the correct license.
def beta_feature_available?(feature)
::Feature.enabled?(feature, self) ||
(::Feature.enabled?(feature) && feature_available?(feature))
::Feature.enabled?(feature) ? feature_available?(feature) : ::Feature.enabled?(feature, self)
end
alias_method :alpha_feature_available?, :beta_feature_available?
......
......@@ -303,8 +303,7 @@ module EE
# it. This is the case when we're ready to enable a feature for anyone
# with the correct license.
def beta_feature_available?(feature)
::Feature.enabled?(feature, self) ||
(::Feature.enabled?(feature) && feature_available?(feature))
::Feature.enabled?(feature) ? feature_available?(feature) : ::Feature.enabled?(feature, self)
end
alias_method :alpha_feature_available?, :beta_feature_available?
......
......@@ -12,28 +12,28 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do
stub_licensed_features(insights: false)
end
context 'when the feature flag is disabled globally' do
context 'when the feature flag is enabled globally' do
before do
stub_feature_flags(insights: false)
stub_feature_flags(insights: true)
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 disabled globally' do
before do
stub_feature_flags(insights: true)
stub_feature_flags(insights: false)
end
it { expect(entity.public_send(method_name, :insights)).to be_truthy }
end
it { expect(entity.public_send(method_name, :insights)).to be_falsy }
context 'when the feature flag is enabled for the entity' do
before do
stub_feature_flags(insights: { enabled: true, thing: entity })
end
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 }
it { expect(entity.public_send(method_name, :insights)).to be_truthy }
end
end
end
......@@ -42,14 +42,6 @@ RSpec.shared_examples 'an entity with alpha/beta feature support' do
stub_licensed_features(insights: true)
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
before do
stub_feature_flags(insights: true)
......@@ -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 }
end
context 'when the feature flag is enabled for the entity' do
context 'when the feature flag is disabled globally' do
before do
stub_feature_flags(insights: { enabled: true, thing: entity })
stub_feature_flags(insights: false)
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
......
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