BigW Consortium Gitlab

container_registry_spec.rb 1.53 KB
Newer Older
1 2 3
require 'spec_helper'

describe "Container Registry" do
4
  let(:user) { create(:user) }
5
  let(:project) { create(:empty_project) }
6 7 8 9

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

  before do
12
    sign_in(user)
13
    project.add_developer(user)
14
    stub_container_registry_config(enabled: true)
15
    stub_container_registry_tags(repository: :any, tags: [])
16 17
  end

18 19 20
  context 'when there are no image repositories' do
    scenario 'user visits container registry main page' do
      visit_container_registry
Kamil Trzcinski committed
21

22
      expect(page).to have_content 'No container images'
23
    end
24 25
  end

26
  context 'when there are image repositories' do
27
    before do
28
      stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest])
29 30 31 32 33 34 35
      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')
36 37
    end

38 39 40
    scenario 'user removes entire container repository' do
      visit_container_registry

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

44
      click_on 'Remove repository'
45 46
    end

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

50 51
      expect_any_instance_of(ContainerRegistry::Tag)
        .to receive(:delete).and_return(true)
Kamil Trzcinski committed
52

53
      click_on 'Remove tag'
54 55
    end
  end
56 57

  def visit_container_registry
58
    visit project_container_registry_index_path(project)
59
  end
Kamil Trzcinski committed
60
end