Validate uniqueness of container repository name
This commit is contained in:
parent
e10dae3e3c
commit
6fefa79430
|
@ -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
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue