summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/config_checker/external_database_checker_spec.rb
blob: 933b6d6be9e6902af115f00a13df9011822c1e36 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do
  describe '#check' do
    subject { described_class.check }

    context 'when database meets minimum supported version' do
      before do
        allow(ApplicationRecord.database).to receive(:postgresql_minimum_supported_version?).and_return(true)
      end

      it { is_expected.to be_empty }
    end

    context 'when database does not meet minimum supported version' do
      before do
        allow(ApplicationRecord.database).to receive(:postgresql_minimum_supported_version?).and_return(false)
      end

      let(:notice_deprecated_database) do
        {
          type: 'warning',
          message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
                     '%{pg_version_minimum} is required for this version of GitLab. ' \
                     'Please upgrade your environment to a supported PostgreSQL version, ' \
                     'see %{pg_requirements_url} for details.') % {
                                                                    pg_version_current: ApplicationRecord.database.version,
                                                                    pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
                                                                    pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>'
                                                                  }
        }
      end

      it 'reports deprecated database notice' do
        is_expected.to contain_exactly(notice_deprecated_database)
      end
    end
  end
end