Commit c25a10bb authored by Peter Leitzen's avatar Peter Leitzen

Fix warning in namespace model

This silences this warning:
    warning: instance variable @plan_name not initialized

Also test explicitly that blank plan names are valid.
parent d63d6e82
......@@ -329,7 +329,7 @@ module EE
private
def validate_plan_name
if @plan_name.present? && PLANS.exclude?(@plan_name) # rubocop:disable Gitlab/ModuleWithInstanceVariables
if defined?(@plan_name) && @plan_name.present? && PLANS.exclude?(@plan_name) # rubocop:disable Gitlab/ModuleWithInstanceVariables
errors.add(:plan, 'is not included in the list')
end
end
......
......@@ -117,12 +117,18 @@ describe Namespace do
end
context 'with an invalid plan name' do
it 'is invalid' do
it 'is invalid when `unknown`' do
group.plan = 'unknown'
expect(group).not_to be_valid
expect(group.errors[:plan]).to include('is not included in the list')
end
it 'is valid for blank strings' do
group.plan = ' '
expect(group).to be_valid
end
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