summaryrefslogtreecommitdiff
path: root/spec/features/container_registry_spec.rb
blob: d5e9de20e59e769e9ad2b585491ef3195197cd39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require 'spec_helper'

describe "Container Registry", :js do
  let(:user) { create(:user) }
  let(:project) { create(:project) }

  let(:container_repository) do
    create(:container_repository, name: 'my/image')
  end

  before do
    sign_in(user)
    project.add_developer(user)
    stub_container_registry_config(enabled: true)
    stub_container_registry_tags(repository: :any, tags: [])
  end

  context 'when there are no image repositories' do
    scenario 'user visits container registry main page' do
      visit_container_registry

      expect(page).to have_content 'No container images'
    end
  end

  context 'when there are image repositories' do
    before do
      stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest])
      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

    scenario 'user removes entire container repository' do
      visit_container_registry

      expect_any_instance_of(ContainerRepository)
        .to receive(:delete_tags!).and_return(true)

      click_on(class: 'js-remove-repo')
    end

    scenario 'user removes a specific tag from container repository' do
      visit_container_registry

      find('.js-toggle-repo').trigger('click')
      wait_for_requests

      expect_any_instance_of(ContainerRegistry::Tag)
        .to receive(:delete).and_return(true)

      click_on(class: 'js-delete-registry')
    end
  end

  def visit_container_registry
    visit project_container_registry_index_path(project)
  end
end