Skip to content
Snippets Groups Projects
Commit 6fefa794 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Validate uniqueness of container repository name

parent e10dae3e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,6 +2,7 @@ class ContainerRepository < ActiveRecord::Base
belongs_to :project
 
validates :name, length: { minimum: 0, allow_nil: false }
validates :name, uniqueness: { scope: :project_id }
 
delegate :client, to: :registry
 
Loading
Loading
Loading
Loading
@@ -21,6 +21,13 @@ describe ContainerRepository do
headers: { 'Content-Type' => 'application/json' })
end
 
describe 'validations' do
it 'validates uniqueness of name scoped to project' do
expect(subject).to validate_uniqueness_of(:name)
.scoped_to(:project_id)
end
end
describe 'associations' do
it 'belongs to the project' do
expect(container_repository).to belong_to(:project)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment