summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb
blob: 8ea307c7c61925107f60fb9825e992f6928b7272 (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
# frozen_string_literal: true

shared_examples 'instance statistics availability' do
  let(:user) { create(:user) }

  before do
    sign_in(user)

    stub_application_setting(usage_ping_enabled: true)
  end

  describe 'GET #index' do
    it 'is available when the feature is available publicly' do
      get :index

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

    it 'renders a 404 when the feature is not available publicly' do
      stub_application_setting(instance_statistics_visibility_private: true)

      get :index

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

    context 'for admins' do
      let(:user) { create(:admin) }

      it 'allows access when the feature is not available publicly' do
        stub_application_setting(instance_statistics_visibility_private: true)

        get :index

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