Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dependency_proxies_controller_spec.rb « groups « controllers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 67847936a80a01ca833dfcc3ef7633b0e56dc656 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Groups::DependencyProxiesController do
  let_it_be(:group) { create(:group) }
  let_it_be_with_reload(:dependency_proxy_group_setting) { create(:dependency_proxy_group_setting, group: group) }
  let_it_be(:user) { create(:user) }

  before do
    group.add_owner(user)
    sign_in(user)
  end

  describe 'GET #show' do
    subject { get :show, params: { group_id: group.to_param } }

    before do
      stub_config(dependency_proxy: { enabled: config_enabled })
    end

    context 'with global config enabled' do
      let(:config_enabled) { true }

      context 'with the setting enabled' do
        it 'returns 200 and renders the view' do
          subject

          expect(response).to have_gitlab_http_status(:ok)
          expect(response).to render_template('groups/dependency_proxies/show')
        end
      end

      context 'with the setting disabled' do
        before do
          dependency_proxy_group_setting.update!(enabled: false)
        end

        it_behaves_like 'returning response status', :not_found
      end
    end

    context 'with global config disabled' do
      let(:config_enabled) { false }

      it_behaves_like 'returning response status', :not_found
    end
  end
end