Commit 6fefa794 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Validate uniqueness of container repository name

parent e10dae3e
......@@ -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)
......
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