Commit 4cc1c629 authored by Robert Speicher's avatar Robert Speicher

Feature flag check in License.feature_available?

parent c996b5e3
......@@ -293,6 +293,9 @@ class License < ActiveRecord::Base
def feature_available?(feature)
return false if trial? && expired?
# This feature might not be behind a feature flag at all, so default to true
return false unless ::Feature.enabled?(feature, default_enabled: true)
features.include?(feature)
end
......
......@@ -569,6 +569,26 @@ describe License do
end
end
end
context 'when feature is disabled by a feature flag' do
it 'returns false' do
feature = license.features.first
stub_feature_flags(feature => false)
expect(license.features).not_to receive(:include?)
expect(license.feature_available?(feature)).to eq(false)
end
end
context 'when feature is enabled by a feature flag' do
it 'returns true' do
feature = license.features.first
stub_feature_flags(feature => true)
expect(license.feature_available?(feature)).to eq(true)
end
end
end
def build_license_with_add_ons(add_ons, plan: nil)
......
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