summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/projects/registry/repositories/_tag.html.haml2
-rw-r--r--spec/features/container_registry_spec.rb65
-rw-r--r--spec/support/stub_gitlab_calls.rb16
3 files changed, 42 insertions, 41 deletions
diff --git a/app/views/projects/registry/repositories/_tag.html.haml b/app/views/projects/registry/repositories/_tag.html.haml
index c9b3644ff93..73566689d57 100644
--- a/app/views/projects/registry/repositories/_tag.html.haml
+++ b/app/views/projects/registry/repositories/_tag.html.haml
@@ -29,6 +29,6 @@
= link_to namespace_project_registry_repository_tag_path(@project.namespace, @project, tag.repository, tag.name),
method: :delete,
class: 'btn btn-remove has-tooltip',
- title: 'Remove image tag',
+ title: 'Remove tag',
data: { confirm: notice } do
= icon('trash cred')
diff --git a/spec/features/container_registry_spec.rb b/spec/features/container_registry_spec.rb
index 530e6af92d3..42431cbe731 100644
--- a/spec/features/container_registry_spec.rb
+++ b/spec/features/container_registry_spec.rb
@@ -1,59 +1,60 @@
require 'spec_helper'
describe "Container Registry" do
+ let(:user) { create(:user) }
let(:project) { create(:empty_project) }
- let(:registry) { project.container_registry }
- let(:tag_name) { 'latest' }
- let(:tags) { [tag_name] }
- let(:container_repository) { create(:container_repository) }
- let(:image_name) { container_repository.name }
+
+ let(:container_repository) do
+ create(:container_repository, name: 'my/image')
+ end
before do
- login_as(:user)
- project.team << [@user, :developer]
+ login_as(user)
+ project.add_developer(user)
stub_container_registry_config(enabled: true)
- stub_container_registry_tags(*tags)
- project.container_repositories << container_repository unless container_repository.nil?
+ stub_container_registry_tags(%w[latest])
end
- describe 'GET /:project/container_registry' do
- before do
- visit namespace_project_container_registry_index_path(project.namespace, project)
- end
-
- context 'when no images' do
- let(:container_repository) { }
-
- it { expect(page).to have_content('No container images in Container Registry for this project') }
- end
+ context 'when there are no image repositories' do
+ scenario 'user visits container registry main page' do
+ visit_container_registry
- context 'when there are images' do
- it { expect(page).to have_content(image_name) }
+ expect(page).to have_content 'No container images'
end
end
- describe 'DELETE /:project/container_registry/:image_id' do
+ context 'when there are image repositories' do
before do
- visit namespace_project_container_registry_index_path(project.namespace, project)
+ project.container_repositories << container_repository
+ end
+
+ scenario 'user wants to see multi-level container repository' do
+ visit_container_registry
+
+ expect(page).to have_content('my/image')
end
- it do
+ scenario 'user removes entire container repository' do
+ visit_container_registry
+
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(true)
- click_on 'Remove image'
+ click_on 'Remove repository'
end
- end
- describe 'DELETE /:project/container_registry/tag' do
- before do
- visit namespace_project_container_registry_index_path(project.namespace, project)
- end
+ scenario 'user removes a specific tag from container repository' do
+ visit_container_registry
- it do
- expect_any_instance_of(::ContainerRegistry::Tag).to receive(:delete).and_return(true)
+ expect_any_instance_of(ContainerRegistry::Tag)
+ .to receive(:delete).and_return(true)
click_on 'Remove tag'
end
end
+
+ def visit_container_registry
+ visit namespace_project_container_registry_index_path(
+ project.namespace, project)
+ end
end
diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb
index 3949784aabb..dbf3ace37c3 100644
--- a/spec/support/stub_gitlab_calls.rb
+++ b/spec/support/stub_gitlab_calls.rb
@@ -32,15 +32,15 @@ module StubGitlabCalls
end
def stub_container_registry_tags(*tags)
- allow_any_instance_of(ContainerRegistry::Client).to receive(:repository_tags).and_return(
- { "tags" => tags }
- )
- allow_any_instance_of(ContainerRegistry::Client).to receive(:repository_manifest).and_return(
- JSON.parse(File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json'))
- )
+ allow_any_instance_of(ContainerRegistry::Client)
+ .to receive(:repository_tags).and_return({ 'tags' => tags })
+
+ allow_any_instance_of(ContainerRegistry::Client)
+ .to receive(:repository_manifest).and_return(
+ JSON.parse(File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json')))
+
allow_any_instance_of(ContainerRegistry::Client).to receive(:blob).and_return(
- File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')
- )
+ File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json'))
end
private