Commit 6fdee1a7 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Additional namespace validation for AdditionalPack

When changing the namespace for Ci::Minutes::AdditionalPacks
we should ensure the namespaces are not the same (unneccessary)

Changelog: other
EE: true
parent 9a1aacfd
...@@ -46,6 +46,7 @@ module Ci ...@@ -46,6 +46,7 @@ module Ci
raise ChangeNamespaceError, 'Target namespace must be provided' unless target.present? raise ChangeNamespaceError, 'Target namespace must be provided' unless target.present?
raise ChangeNamespaceError, 'Namespace must be a top-level namespace' unless namespace.root? raise ChangeNamespaceError, 'Namespace must be a top-level namespace' unless namespace.root?
raise ChangeNamespaceError, 'Target namespace must be a top-level namespace' unless target.root? raise ChangeNamespaceError, 'Target namespace must be a top-level namespace' unless target.root?
raise ChangeNamespaceError, 'Namespace and target must be different' if namespace == target
end end
def validate_owners! def validate_owners!
......
...@@ -111,6 +111,15 @@ RSpec.describe Ci::Minutes::AdditionalPacks::ChangeNamespaceService do ...@@ -111,6 +111,15 @@ RSpec.describe Ci::Minutes::AdditionalPacks::ChangeNamespaceService do
expect(change_namespace[:message]).to eq 'Both namespaces must share the same owner' expect(change_namespace[:message]).to eq 'Both namespaces must share the same owner'
end end
end end
context 'when the namespace is the same as the target' do
let(:target) { namespace }
it 'returns an error' do
expect(change_namespace[:status]).to eq :error
expect(change_namespace[:message]).to eq 'Namespace and target must be different'
end
end
end end
end 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