Commit 4f405cdc authored by Nick Thomas's avatar Nick Thomas

Fix implicit license plans

Licenses without a plan specified need to act as though they are EES. This is
currently implemented for licenses that don't include a plan in their data at
all, but if `plan: nil` or `plan: ""` is set, the customer loses access to a
number of features with license checks added in 9.4. This commit changes the
license check to use the starter plan in those cases too.
parent 6f1b2005
......@@ -258,7 +258,7 @@ class License < ActiveRecord::Base
end
def plan
restricted_attr(:plan, STARTER_PLAN)
restricted_attr(:plan).presence || STARTER_PLAN
end
def current_active_users_count
......
......@@ -375,23 +375,29 @@ describe License do
describe 'reading add-ons' do
describe '#plan' do
it 'interprets no plan as EES' do
license = build(:license, data: build(:gitlab_license, restrictions: { add_ons: {} }).export)
let(:gl_license) { build(:gitlab_license, restrictions: restrictions.merge(add_ons: {})) }
let(:license) { build(:license, data: gl_license.export) }
expect(license.plan).to eq(License::STARTER_PLAN)
end
subject { license.plan }
it 'interprets an unknown plan as unknown' do
license = build_license_with_add_ons({}, plan: 'unknown')
[
{ restrictions: {}, plan: License::STARTER_PLAN },
{ restrictions: { plan: nil }, plan: License::STARTER_PLAN },
{ restrictions: { plan: '' }, plan: License::STARTER_PLAN },
{ restrictions: { plan: 'unknown' }, plan: 'unknown' }
].each do |spec|
context spec.inspect do
let(:restrictions) { spec[:restrictions] }
expect(license.plan).to eq('unknown')
it { is_expected.to eq(spec[:plan]) }
end
end
end
describe '#add_ons' do
context 'without add-ons' do
it 'returns an empty Hash' do
license = build_license_with_add_ons({})
license = build_license_with_add_ons({}, plan: 'unknown')
expect(license.add_ons).to eq({})
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