container_registry_spec.rb 1.28 KB
Newer Older
1
2
3
4
5
6
7
require 'spec_helper'

describe "Container Registry" do
  let(:project) { create(:empty_project) }
  let(:repository) { project.container_registry_repository }
  let(:tag_name) { 'latest' }
  let(:tags) { [tag_name] }
Kamil Trzcinski's avatar
Kamil Trzcinski committed
8
9
10
11
  let(:registry_settings) do
    {
      enabled: true
    }
12
13
14
15
16
17
  end

  before do
    login_as(:user)
    project.team << [@user, :developer]
    stub_container_registry(*tags)
Kamil Trzcinski's avatar
Kamil Trzcinski committed
18
    allow(Gitlab.config.registry).to receive_messages(registry_settings)
19
    allow(Auth::ContainerRegistryAuthenticationService).to receive(:full_access_token).and_return('token')
20
21
22
23
24
25
26
27
28
  end

  describe 'GET /:project/container_registry' do
    before do
      visit namespace_project_container_registry_index_path(project.namespace, project)
    end

    context 'when no tags' do
      let(:tags) { [] }
Kamil Trzcinski's avatar
Kamil Trzcinski committed
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
      it { expect(page).to have_content('No images in Container Registry for this project') }
    end

    context 'when there are tags' do
      it { expect(page).to have_content(tag_name)}
    end
  end

  describe 'DELETE /:project/container_registry/tag' do
    before do
      visit namespace_project_container_registry_index_path(project.namespace, project)
    end

    it do
      expect_any_instance_of(::ContainerRegistry::Tag).to receive(:delete).and_return(true)
Kamil Trzcinski's avatar
Kamil Trzcinski committed
45

46
47
48
      click_on 'Remove'
    end
  end
Kamil Trzcinski's avatar
Kamil Trzcinski committed
49
end