From e7b5a68daecd0aff0cc66666cb38c7971027a05a Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 28 Aug 2020 13:14:44 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-3-stable-ee --- .../external_database_checker_spec.rb | 81 +++++----------------- 1 file changed, 16 insertions(+), 65 deletions(-) (limited to 'spec/lib/gitlab/config_checker/external_database_checker_spec.rb') diff --git a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb index 712903e020a..85bafc77553 100644 --- a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb +++ b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb @@ -6,84 +6,35 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do describe '#check' do subject { described_class.check } - let_it_be(:deprecation_warning) { "Please upgrade" } - let_it_be(:upcoming_deprecation_warning) { "Please consider upgrading" } - - context 'when database meets minimum version and there is no upcoming deprecation' do + context 'when database meets minimum supported version' do before do allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false) end it { is_expected.to be_empty } end - context 'when database does not meet minimum version and there is no upcoming deprecation' do + context 'when database does not meet minimum supported version' do before do allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false) - end - - it 'only returns notice about deprecated database version' do - is_expected.to include(a_hash_including(message: include(deprecation_warning))) - is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning))) end - end - context 'when database meets minimum version and there is an upcoming deprecation' do - before do - allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true) + 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: Gitlab::Database.version, + pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION, + pg_requirements_url: 'database requirements' + } + } end - context 'inside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true) - end - - it 'only returns notice about an upcoming deprecation' do - is_expected.to include(a_hash_including(message: include(upcoming_deprecation_warning))) - is_expected.not_to include(a_hash_including(message: include(deprecation_warning))) - end - end - - context 'outside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false) - end - - it { is_expected.to be_empty } - end - end - - context 'when database does not meet minimum version and there is an upcoming deprecation' do - before do - allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true) - end - - context 'inside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true) - end - - it 'returns notice about deprecated database version and an upcoming deprecation' do - is_expected.to include( - a_hash_including(message: include(deprecation_warning)), - a_hash_including(message: include(upcoming_deprecation_warning)) - ) - end - end - - context 'outside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false) - end - - it 'only returns notice about deprecated database version' do - is_expected.to include(a_hash_including(message: include(deprecation_warning))) - is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning))) - end + it 'reports deprecated database notice' do + is_expected.to contain_exactly(notice_deprecated_database) end end end -- cgit v1.2.3