diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-28 13:14:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-28 13:14:44 +0000 |
commit | e7b5a68daecd0aff0cc66666cb38c7971027a05a (patch) | |
tree | b153db785557cc807da5e623cb130a1ef384926e /spec | |
parent | c8fb2e6a3942330079bde06d919cd33c6bc7600e (diff) | |
download | gitlab-ce-e7b5a68daecd0aff0cc66666cb38c7971027a05a.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 15 | ||||
-rw-r--r-- | spec/frontend/snippets/components/edit_spec.js | 2 | ||||
-rw-r--r-- | spec/graphql/resolvers/issue_status_counts_resolver_spec.rb | 35 | ||||
-rw-r--r-- | spec/lib/backup/repository_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/config_checker/external_database_checker_spec.rb | 81 | ||||
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 40 |
6 files changed, 59 insertions, 116 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 469e58c94e7..78de89de796 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -555,6 +555,21 @@ RSpec.describe GroupsController do end end + context 'when there is a conflicting group path' do + render_views + + let!(:conflict_group) { create(:group, path: SecureRandom.hex(12) ) } + let!(:old_name) { group.name } + + it 'does not render references to the conflicting group' do + put :update, params: { id: group.to_param, group: { path: conflict_group.path } } + + expect(response).to have_gitlab_http_status(:ok) + expect(group.reload.name).to eq(old_name) + expect(response.body).not_to include(conflict_group.path) + end + end + context 'when a project inside the group has container repositories' do before do stub_container_registry_config(enabled: true) diff --git a/spec/frontend/snippets/components/edit_spec.js b/spec/frontend/snippets/components/edit_spec.js index 980855a0615..ebab6aa84f6 100644 --- a/spec/frontend/snippets/components/edit_spec.js +++ b/spec/frontend/snippets/components/edit_spec.js @@ -179,7 +179,7 @@ describe('Snippet Edit app', () => { ${'foo'} | ${[]} | ${false} ${'foo'} | ${[TEST_ACTIONS.VALID]} | ${false} ${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_CONTENT]} | ${true} - ${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_PATH]} | ${true} + ${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_PATH]} | ${false} `( 'should handle submit disable (title=$title, actions=$actions, shouldDisable=$shouldDisable)', async ({ title, actions, shouldDisable }) => { diff --git a/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb b/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb index d2412db35c6..69e940ee6ca 100644 --- a/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb +++ b/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb @@ -7,14 +7,21 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do describe '#resolve' do let_it_be(:current_user) { create(:user) } - let_it_be(:project) { create(:project) } - let_it_be(:issue) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + let_it_be(:issue) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) } let_it_be(:incident) { create(:incident, project: project, state: :closed, created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) } + # This issue should not be included in the counts + let_it_be(:other_project) { create(:project) } + let_it_be(:other_proj_issue) { create(:issue, state: :opened, project: other_project) } + + let(:parent) { project } let(:args) { {} } - before do + before_all do project.add_developer(current_user) + other_project.add_developer(current_user) end subject { resolve_issue_status_counts(args) } @@ -22,12 +29,22 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do it { is_expected.to be_a(Gitlab::IssuablesCountForState) } specify { expect(subject.project).to eq(project) } - it 'returns expected results' do - result = resolve_issue_status_counts + shared_examples 'returns expected results' do + it 'returns expected results', :aggregate_failures do + result = resolve_issue_status_counts - expect(result.all).to eq 2 - expect(result.opened).to eq 1 - expect(result.closed).to eq 1 + expect(result.all).to eq 2 + expect(result.opened).to eq 1 + expect(result.closed).to eq 1 + end + end + + it_behaves_like 'returns expected results' + + context 'group used as parent' do + let(:parent) { project.group } + + it_behaves_like 'returns expected results' end it 'filters by search', :aggregate_failures do @@ -58,7 +75,7 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do private def resolve_issue_status_counts(args = {}, context = { current_user: current_user }) - resolve(described_class, obj: project, args: args, ctx: context) + resolve(described_class, obj: parent, args: args, ctx: context) end end end diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index fef5e018231..c4ad239f9d7 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -55,7 +55,7 @@ RSpec.describe Backup::Repository do end [4, 10].each do |max_storage_concurrency| - context "max_storage_concurrency #{max_storage_concurrency}" do + context "max_storage_concurrency #{max_storage_concurrency}", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/241701' do it 'creates the expected number of threads' do expect(Thread).to receive(:new) .exactly(storage_keys.length * (max_storage_concurrency + 1)).times 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: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>' + } + } 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 diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 47d2cb05240..420aa0a8df6 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -109,46 +109,6 @@ RSpec.describe Gitlab::Database do end end - describe '.postgresql_upcoming_deprecation?' do - it 'returns true when database version is lower than the upcoming minimum' do - allow(described_class).to receive(:version).and_return('11') - - expect(described_class.postgresql_upcoming_deprecation?).to eq(true) - end - - it 'returns false when database version equals the upcoming minimum' do - allow(described_class).to receive(:version).and_return('12') - - expect(described_class.postgresql_upcoming_deprecation?).to eq(false) - end - - it 'returns false when database version is greater the upcoming minimum' do - allow(described_class).to receive(:version).and_return('13') - - expect(described_class.postgresql_upcoming_deprecation?).to eq(false) - end - end - - describe '.within_deprecation_notice_window?' do - using RSpec::Parameterized::TableSyntax - - where(:case_name, :days, :result) do - 'outside window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS + 1 | false - 'equal to window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS | true - 'within window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS - 1 | true - end - - with_them do - it "returns #{params[:result]} when #{params[:case_name]}" do - allow(Date) - .to receive(:today) - .and_return Date.parse(Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) - days - - expect(described_class.within_deprecation_notice_window?).to eq(result) - end - end - end - describe '.check_postgres_version_and_print_warning' do subject { described_class.check_postgres_version_and_print_warning } |