File: dashboard_controller_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (65 lines) | stat: -rw-r--r-- 1,657 bytes parent folder | download
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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Admin::DashboardController do
  describe '#index' do
    before do
      sign_in(create(:admin))
    end

    it 'retrieves Redis versions' do
      get :index

      # specs are run against both Redis and Redis Cluster instances.
      expect(assigns[:redis_versions].length).to be > 0
    end

    context 'with pending_delete projects' do
      render_views

      it 'does not retrieve projects that are pending deletion' do
        project = create(:project)
        pending_delete_project = create(:project, pending_delete: true)

        get :index

        expect(response.body).to match(project.name)
        expect(response.body).not_to match(pending_delete_project.name)
      end
    end

    describe 'GitLab KAS', feature_category: :deployment_management do
      before do
        allow(Gitlab::Kas).to receive(:enabled?).and_return(enabled)
      end

      context 'with kas enabled' do
        let(:enabled) { true }

        before do
          response = instance_double(Gitlab::Agent::ServerInfo::ServerInfo)
          allow_next_instance_of(Gitlab::Kas::Client) do |instance|
            allow(instance).to receive(:get_server_info).and_return(response)
          end
        end

        it 'retrieves and displays kas version' do
          get :index

          expect(assigns[:kas_server_info]).to be_present
        end
      end

      context 'with kas disabled' do
        let(:enabled) { false }

        it 'does not retrieve kas source' do
          get :index

          expect(assigns[:kas_server_info]).to be_nil
        end
      end
    end
  end
end