diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:27:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:27:09 +0000 |
commit | bcc70301531b6c3118120173389f2aaa7452bf11 (patch) | |
tree | 161f1ee56e15ec9e59f48c5e1a9cb86b62469a49 /spec | |
parent | d47fc5085a706ab37d038636c9d5934da69853f0 (diff) | |
download | gitlab-ce-bcc70301531b6c3118120173389f2aaa7452bf11.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec')
6 files changed, 106 insertions, 15 deletions
diff --git a/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb b/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb index 2381e00972f..8070fee5804 100644 --- a/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb +++ b/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb @@ -46,7 +46,7 @@ RSpec.describe 'User uploads new design', :js do let(:feature_enabled) { false } it 'shows the message about requirements' do - expect(page).to have_content("To enable design management, you'll need to meet the requirements.") + expect(page).to have_content("To upload designs, you'll need to enable LFS.") end end end @@ -80,7 +80,7 @@ RSpec.describe 'User uploads new design', :js do let(:feature_enabled) { false } it 'shows the message about requirements' do - expect(page).to have_content("To enable design management, you'll need to meet the requirements.") + expect(page).to have_content("To upload designs, you'll need to enable LFS.") end end end diff --git a/spec/frontend/design_management_new/pages/__snapshots__/index_spec.js.snap b/spec/frontend/design_management_new/pages/__snapshots__/index_spec.js.snap index 3d1fe143ac3..902803b0ad1 100644 --- a/spec/frontend/design_management_new/pages/__snapshots__/index_spec.js.snap +++ b/spec/frontend/design_management_new/pages/__snapshots__/index_spec.js.snap @@ -2,7 +2,7 @@ exports[`Design management index page designs does not render toolbar when there is no permission 1`] = ` <div - class="gl-mt-5" + class="gl-mt-5 designs-root" data-testid="designs-root" > <!----> @@ -87,7 +87,7 @@ exports[`Design management index page designs does not render toolbar when there exports[`Design management index page designs renders designs list and header with upload button 1`] = ` <div - class="gl-mt-5" + class="gl-mt-5 designs-root" data-testid="designs-root" > <header diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js index ec6ad031813..fc5e39357ca 100644 --- a/spec/frontend/diffs/store/actions_spec.js +++ b/spec/frontend/diffs/store/actions_spec.js @@ -1603,6 +1603,18 @@ describe('DiffsStoreActions', () => { expect(commit).toHaveBeenCalledWith(types.UPDATE_CURRENT_DIFF_FILE_ID, '123'); }); + + it('does not commit UPDATE_CURRENT_DIFF_FILE_ID when discussion has no diff_file', () => { + const commit = jest.fn(); + const rootGetters = { + getDiscussion: () => ({ id: '1' }), + notesById: { '1': { discussion_id: '2' } }, + }; + + setCurrentDiffFileIdFromNote({ commit, rootGetters }, '1'); + + expect(commit).not.toHaveBeenCalled(); + }); }); describe('navigateToDiffFileIndex', () => { 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 316696bc584..712903e020a 100644 --- a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb +++ b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb @@ -36,9 +36,23 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).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))) + 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 @@ -48,11 +62,28 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).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)) - ) + 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 end end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index cd009f955af..47d2cb05240 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -129,6 +129,26 @@ RSpec.describe Gitlab::Database do 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 } diff --git a/spec/models/concerns/approvable_base_spec.rb b/spec/models/concerns/approvable_base_spec.rb index 8fda8bccf09..a9e944cf220 100644 --- a/spec/models/concerns/approvable_base_spec.rb +++ b/spec/models/concerns/approvable_base_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' RSpec.describe ApprovableBase do - describe '#approved_by?' do - let(:merge_request) { create(:merge_request) } - let(:user) { create(:user) } + let(:merge_request) { create(:merge_request) } + let(:user) { create(:user) } + describe '#approved_by?' do subject { merge_request.approved_by?(user) } context 'when a user has not approved' do @@ -31,4 +31,32 @@ RSpec.describe ApprovableBase do end end end + + describe '#can_be_approved_by?' do + subject { merge_request.can_be_approved_by?(user) } + + before do + merge_request.project.add_developer(user) + end + + it 'returns true' do + is_expected.to be_truthy + end + + context 'when a user has approved' do + let!(:approval) { create(:approval, merge_request: merge_request, user: user) } + + it 'returns false' do + is_expected.to be_falsy + end + end + + context 'when a user is nil' do + let(:user) { nil } + + it 'returns false' do + is_expected.to be_falsy + end + end + end end |