Commit 08b1302d authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Allow saving no plan on namespaces

parent 211679e2
......@@ -24,7 +24,7 @@ module EE
delegate :shared_runners_minutes, :shared_runners_seconds, :shared_runners_seconds_last_reset,
to: :namespace_statistics, allow_nil: true
validates :plan, inclusion: { in: EE_PLANS.keys }, allow_nil: true
validates :plan, inclusion: { in: EE_PLANS.keys }, allow_blank: true
end
# Checks features (i.e. https://about.gitlab.com/products/) availabily
......@@ -58,7 +58,7 @@ module EE
def plans
@ancestors_plans ||=
if parent_id
ancestors.where.not(plan: nil).reorder(nil).pluck('DISTINCT plan') + [plan]
ancestors.where.not(plan: [nil, '']).reorder(nil).pluck('DISTINCT plan') + [plan]
else
[plan]
end
......
.form-group
= f.label :plan, class: 'control-label'
.col-sm-10
= f.select :plan, options_for_select(Namespace::EE_PLANS.keys.map { |plan| [plan.titleize, plan] }, f.object.plan), {}, class: 'form-control'
= f.select :plan, options_for_select(Namespace::EE_PLANS.keys.map { |plan| [plan.titleize, plan] }, f.object.plan),
{ include_blank: 'No associated plan' },
class: 'form-control'
......@@ -8,7 +8,7 @@ describe Namespace, models: true do
it { is_expected.to delegate_method(:shared_runners_minutes).to(:namespace_statistics) }
it { is_expected.to delegate_method(:shared_runners_seconds).to(:namespace_statistics) }
it { is_expected.to delegate_method(:shared_runners_seconds_last_reset).to(:namespace_statistics) }
it { is_expected.to validate_inclusion_of(:plan).in_array(Namespace::EE_PLANS.keys).allow_nil }
it { is_expected.to validate_inclusion_of(:plan).in_array(Namespace::EE_PLANS.keys).allow_blank }
describe '#feature_available?' do
let(:group) { create(:group, plan: plan_license) }
......
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