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

Allow saving no plan on namespaces

parent 211679e2
...@@ -24,7 +24,7 @@ module EE ...@@ -24,7 +24,7 @@ module EE
delegate :shared_runners_minutes, :shared_runners_seconds, :shared_runners_seconds_last_reset, delegate :shared_runners_minutes, :shared_runners_seconds, :shared_runners_seconds_last_reset,
to: :namespace_statistics, allow_nil: true 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 end
# Checks features (i.e. https://about.gitlab.com/products/) availabily # Checks features (i.e. https://about.gitlab.com/products/) availabily
...@@ -58,7 +58,7 @@ module EE ...@@ -58,7 +58,7 @@ module EE
def plans def plans
@ancestors_plans ||= @ancestors_plans ||=
if parent_id 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 else
[plan] [plan]
end end
......
.form-group .form-group
= f.label :plan, class: 'control-label' = f.label :plan, class: 'control-label'
.col-sm-10 .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 ...@@ -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_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).to(:namespace_statistics) }
it { is_expected.to delegate_method(:shared_runners_seconds_last_reset).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 describe '#feature_available?' do
let(:group) { create(:group, plan: plan_license) } 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