summaryrefslogtreecommitdiff
path: root/spec/requests/projects/harbor/repositories_controller_spec.rb
blob: cdb5a696d7ea8fab982defeb2a0ae1e028322933 (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
64
65
66
67
68
69
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Projects::Harbor::RepositoriesController do
  let_it_be(:project, reload: true) { create(:project) }
  let_it_be(:user) { create(:user) }

  shared_examples 'responds with 404 status' do
    it 'returns 404' do
      subject

      expect(response).to have_gitlab_http_status(:not_found)
    end
  end

  shared_examples 'responds with 200 status' do
    it 'renders the index template' do
      subject

      expect(response).to have_gitlab_http_status(:ok)
      expect(response).to render_template(:index)
    end
  end

  before do
    stub_feature_flags(harbor_registry_integration: true)
    project.add_developer(user)
    sign_in(user)
  end

  describe 'GET #index' do
    subject do
      get project_harbor_registry_index_path(project)
      response
    end

    context 'with harbor registry feature flag enabled' do
      it_behaves_like 'responds with 200 status'
    end

    context 'with harbor registry feature flag disabled' do
      before do
        stub_feature_flags(harbor_registry_integration: false)
      end

      it_behaves_like 'responds with 404 status'
    end
  end

  describe 'GET #show' do
    subject do
      get project_harbor_registry_path(project, 1)
      response
    end

    context 'with harbor registry feature flag enabled' do
      it_behaves_like 'responds with 200 status'
    end

    context 'with harbor registry feature flag disabled' do
      before do
        stub_feature_flags(harbor_registry_integration: false)
      end

      it_behaves_like 'responds with 404 status'
    end
  end
end