Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-30 14:45:54 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-30 14:45:54 +0300
commit003a51d17aea6af92953f7207e2b39a5cb6db8de (patch)
tree37204d4149b2c63fd0daea365e4a358b820a7882 /spec/services
parent031122eb54390b4ed792289237ecfb156ec69002 (diff)
Check container repository exists for a given path
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/container_registry/create_repository_service_spec.rb31
1 files changed, 16 insertions, 15 deletions
diff --git a/spec/services/container_registry/create_repository_service_spec.rb b/spec/services/container_registry/create_repository_service_spec.rb
index dfd07c8cc02..ac7b147f92e 100644
--- a/spec/services/container_registry/create_repository_service_spec.rb
+++ b/spec/services/container_registry/create_repository_service_spec.rb
@@ -14,18 +14,6 @@ describe ContainerRegistry::CreateRepositoryService, '#execute' do
stub_container_registry_config(enabled: true)
end
- context 'when container repository already exists' do
- before do
- create(:container_repository, project: project, name: 'my/image')
- end
-
- it 'does not create container repository again' do
- expect { service.execute(path) }
- .to raise_error(Gitlab::Access::AccessDeniedError)
- .and change { ContainerRepository.count }.by(0)
- end
- end
-
context 'when repository is created by an user' do
context 'when user has no ability to create a repository' do
it 'does not create a new container repository' do
@@ -40,9 +28,22 @@ describe ContainerRegistry::CreateRepositoryService, '#execute' do
project.add_developer(user)
end
- it 'creates a new container repository' do
- expect { service.execute(path) }
- .to change { project.container_repositories.count }.by(1)
+ context 'when repository already exists' do
+ before do
+ create(:container_repository, project: project, name: 'my/image')
+ end
+
+ it 'does not create container repository again' do
+ expect { service.execute(path) }
+ .to_not change { ContainerRepository.count }
+ end
+ end
+
+ context 'when repository does not exist yet' do
+ it 'creates a new container repository' do
+ expect { service.execute(path) }
+ .to change { project.container_repositories.count }.by(1)
+ end
end
end
end