Commit 629a37f3 authored by Sean McGivern's avatar Sean McGivern

Merge branch '2929-fix-implicit-license-plan' into 'master'

Fix implicit license plans

Closes #2929

See merge request !2427
parents f6482f1c 4f405cdc
...@@ -262,7 +262,7 @@ class License < ActiveRecord::Base ...@@ -262,7 +262,7 @@ class License < ActiveRecord::Base
end end
def plan def plan
restricted_attr(:plan, STARTER_PLAN) restricted_attr(:plan).presence || STARTER_PLAN
end end
def current_active_users_count def current_active_users_count
......
...@@ -375,23 +375,29 @@ describe License do ...@@ -375,23 +375,29 @@ describe License do
describe 'reading add-ons' do describe 'reading add-ons' do
describe '#plan' do describe '#plan' do
it 'interprets no plan as EES' do let(:gl_license) { build(:gitlab_license, restrictions: restrictions.merge(add_ons: {})) }
license = build(:license, data: build(:gitlab_license, restrictions: { add_ons: {} }).export) let(:license) { build(:license, data: gl_license.export) }
expect(license.plan).to eq(License::STARTER_PLAN) subject { license.plan }
end
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
end end
describe '#add_ons' do describe '#add_ons' do
context 'without add-ons' do context 'without add-ons' do
it 'returns an empty Hash' 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({}) expect(license.add_ons).to eq({})
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