diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-13 18:10:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-13 18:10:34 +0300 |
commit | 85d19f5eac32e61cc0b69768523c15cc1e179389 (patch) | |
tree | 56dc9934b0f7e96b4b1365acb28e0f59008d31ce /spec | |
parent | 0c762fd1b77efe62beb37f9617100724bb2ed2f9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
18 files changed, 81 insertions, 140 deletions
diff --git a/spec/controllers/projects/learn_gitlab_controller_spec.rb b/spec/controllers/projects/learn_gitlab_controller_spec.rb index 90d00767f92..620982f73be 100644 --- a/spec/controllers/projects/learn_gitlab_controller_spec.rb +++ b/spec/controllers/projects/learn_gitlab_controller_spec.rb @@ -7,13 +7,13 @@ RSpec.describe Projects::LearnGitlabController do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, namespace: user.namespace) } - let(:learn_gitlab_experiment_enabled) { true } + let(:learn_gitlab_enabled) { true } let(:params) { { namespace_id: project.namespace.to_param, project_id: project } } subject { get :index, params: params } before do - allow(controller.helpers).to receive(:learn_gitlab_experiment_enabled?).and_return(learn_gitlab_experiment_enabled) + allow(controller.helpers).to receive(:learn_gitlab_enabled?).and_return(learn_gitlab_enabled) end context 'unauthenticated user' do @@ -28,7 +28,7 @@ RSpec.describe Projects::LearnGitlabController do it { is_expected.to render_template(:index) } context 'learn_gitlab experiment not enabled' do - let(:learn_gitlab_experiment_enabled) { false } + let(:learn_gitlab_enabled) { false } it { is_expected.to have_gitlab_http_status(:not_found) } end diff --git a/spec/features/groups/packages_spec.rb b/spec/features/groups/packages_spec.rb index 9a7950266a5..3c2ade6b274 100644 --- a/spec/features/groups/packages_spec.rb +++ b/spec/features/groups/packages_spec.rb @@ -44,14 +44,6 @@ RSpec.describe 'Group Packages' do it_behaves_like 'packages list', check_project_name: true - context 'when package_details_apollo feature flag is off' do - before do - stub_feature_flags(package_details_apollo: false) - end - - it_behaves_like 'package details link' - end - it_behaves_like 'package details link' it 'allows you to navigate to the project page' do diff --git a/spec/features/projects/package_files_spec.rb b/spec/features/projects/package_files_spec.rb index c5c03396d71..6dc0294bb9e 100644 --- a/spec/features/projects/package_files_spec.rb +++ b/spec/features/projects/package_files_spec.rb @@ -23,20 +23,6 @@ RSpec.describe 'PackageFiles' do expect(status_code).to eq(200) end - context 'when package_details_apollo feature flag is off' do - before do - stub_feature_flags(package_details_apollo: false) - end - - it 'renders the download link with the correct url', :js do - visit project_package_path(project, package) - - download_url = download_project_package_file_path(project, package_file) - - expect(page).to have_link(package_file.file_name, href: download_url) - end - end - it 'does not allow download of package belonging to different project' do another_package = create(:maven_package) another_file = another_package.package_files.first diff --git a/spec/features/projects/packages_spec.rb b/spec/features/projects/packages_spec.rb index 30298f79312..7fcc8200b1c 100644 --- a/spec/features/projects/packages_spec.rb +++ b/spec/features/projects/packages_spec.rb @@ -37,14 +37,6 @@ RSpec.describe 'Packages' do it_behaves_like 'packages list' - context 'when package_details_apollo feature flag is off' do - before do - stub_feature_flags(package_details_apollo: false) - end - - it_behaves_like 'package details link' - end - it_behaves_like 'package details link' context 'deleting a package' do diff --git a/spec/frontend/boards/board_card_inner_spec.js b/spec/frontend/boards/board_card_inner_spec.js index 7d3ecc773a6..e0446811f64 100644 --- a/spec/frontend/boards/board_card_inner_spec.js +++ b/spec/frontend/boards/board_card_inner_spec.js @@ -2,6 +2,7 @@ import { GlLabel, GlLoadingIcon, GlTooltip } from '@gitlab/ui'; import { range } from 'lodash'; import Vuex from 'vuex'; import setWindowLocation from 'helpers/set_window_location_helper'; +import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import BoardBlockedIcon from '~/boards/components/board_blocked_icon.vue'; import BoardCardInner from '~/boards/components/board_card_inner.vue'; @@ -44,6 +45,7 @@ describe('Board card component', () => { const findEpicBadgeProgress = () => wrapper.findByTestId('epic-progress'); const findEpicCountablesTotalWeight = () => wrapper.findByTestId('epic-countables-total-weight'); const findEpicProgressTooltip = () => wrapper.findByTestId('epic-progress-tooltip-content'); + const findHiddenIssueIcon = () => wrapper.findByTestId('hidden-icon'); const createStore = ({ isEpicBoard = false, isProjectBoard = false } = {}) => { store = new Vuex.Store({ @@ -72,6 +74,9 @@ describe('Board card component', () => { GlLabel: true, GlLoadingIcon: true, }, + directives: { + GlTooltip: createMockDirective(), + }, mocks: { $apollo: { queries: { @@ -122,6 +127,10 @@ describe('Board card component', () => { expect(wrapper.find('.confidential-icon').exists()).toBe(false); }); + it('does not render hidden issue icon', () => { + expect(findHiddenIssueIcon().exists()).toBe(false); + }); + it('renders issue ID with #', () => { expect(wrapper.find('.board-card-number').text()).toContain(`#${issue.iid}`); }); @@ -184,6 +193,30 @@ describe('Board card component', () => { }); }); + describe('hidden issue', () => { + beforeEach(() => { + wrapper.setProps({ + item: { + ...wrapper.props('item'), + hidden: true, + }, + }); + }); + + it('renders hidden issue icon', () => { + expect(findHiddenIssueIcon().exists()).toBe(true); + }); + + it('displays a tooltip which explains the meaning of the icon', () => { + const tooltip = getBinding(findHiddenIssueIcon().element, 'gl-tooltip'); + + expect(tooltip).toBeDefined(); + expect(findHiddenIssueIcon().attributes('title')).toBe( + 'This issue is hidden because its author has been banned', + ); + }); + }); + describe('with assignee', () => { describe('with avatar', () => { beforeEach(() => { diff --git a/spec/frontend/projects/storage_counter/mock_data.js b/spec/frontend/projects/storage_counter/mock_data.js index a7e19e679d2..8561a2714c6 100644 --- a/spec/frontend/projects/storage_counter/mock_data.js +++ b/spec/frontend/projects/storage_counter/mock_data.js @@ -4,6 +4,7 @@ export const mockGetProjectStorageCountGraphQLResponse = { id: 'gid://gitlab/Project/20', statistics: { buildArtifactsSize: 400000.0, + pipelineArtifactsSize: 25000.0, lfsObjectsSize: 4800000.0, packagesSize: 3800000.0, repositorySize: 3900000.0, diff --git a/spec/helpers/learn_gitlab_helper_spec.rb b/spec/helpers/learn_gitlab_helper_spec.rb index f148dd4a8ba..1159fd96d59 100644 --- a/spec/helpers/learn_gitlab_helper_spec.rb +++ b/spec/helpers/learn_gitlab_helper_spec.rb @@ -53,7 +53,7 @@ RSpec.describe LearnGitlabHelper do end end - describe '.learn_gitlab_experiment_enabled?' do + describe '.learn_gitlab_enabled?' do using RSpec::Parameterized::TableSyntax let_it_be(:user) { create(:user) } @@ -61,7 +61,7 @@ RSpec.describe LearnGitlabHelper do let(:params) { { namespace_id: project.namespace.to_param, project_id: project } } - subject { helper.learn_gitlab_experiment_enabled?(project) } + subject { helper.learn_gitlab_enabled?(project) } where(:onboarding, :learn_gitlab_available, :result) do true | true | true diff --git a/spec/helpers/packages_helper_spec.rb b/spec/helpers/packages_helper_spec.rb index bc60c582ff8..06c6cccd488 100644 --- a/spec/helpers/packages_helper_spec.rb +++ b/spec/helpers/packages_helper_spec.rb @@ -223,21 +223,41 @@ RSpec.describe PackagesHelper do describe '#package_details_data' do let_it_be(:package) { create(:package) } + let(:expected_result) do + { + package_id: package.id, + can_delete: 'true', + project_name: project.name, + group_list_url: '' + } + end + before do allow(helper).to receive(:current_user) { project.owner } allow(helper).to receive(:can?) { true } end - it 'when use_presenter is true populate the package key' do - result = helper.package_details_data(project, package, true) + context 'in a project without a group' do + it 'populates presenter data' do + result = helper.package_details_data(project, package) - expect(result[:package]).not_to be_nil + expect(result).to match(hash_including(expected_result)) + end end - it 'when use_presenter is false the package key is nil' do - result = helper.package_details_data(project, package, false) + context 'in a project with a group' do + let_it_be(:group) { create(:group) } + let_it_be(:project_with_group) { create(:project, group: group) } - expect(result[:package]).to be_nil + it 'populates presenter data' do + result = helper.package_details_data(project_with_group, package) + expected = expected_result.merge({ + group_list_url: group_packages_path(project_with_group.group), + project_name: project_with_group.name + }) + + expect(result).to match(hash_including(expected)) + end end end end diff --git a/spec/lib/sidebars/projects/menus/learn_gitlab_menu_spec.rb b/spec/lib/sidebars/projects/menus/learn_gitlab_menu_spec.rb index a0f93efbda3..36a76e70a48 100644 --- a/spec/lib/sidebars/projects/menus/learn_gitlab_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/learn_gitlab_menu_spec.rb @@ -4,13 +4,13 @@ require 'spec_helper' RSpec.describe Sidebars::Projects::Menus::LearnGitlabMenu do let_it_be(:project) { build(:project) } - let_it_be(:experiment_enabled) { true } + let_it_be(:learn_gitlab_enabled) { true } let(:context) do Sidebars::Projects::Context.new( current_user: nil, container: project, - learn_gitlab_experiment_enabled: experiment_enabled + learn_gitlab_enabled: learn_gitlab_enabled ) end @@ -43,7 +43,7 @@ RSpec.describe Sidebars::Projects::Menus::LearnGitlabMenu do end context 'when learn gitlab experiment is disabled' do - let(:experiment_enabled) { false } + let(:learn_gitlab_enabled) { false } it 'returns false' do expect(subject.render?).to eq false @@ -59,7 +59,7 @@ RSpec.describe Sidebars::Projects::Menus::LearnGitlabMenu do end context 'when learn gitlab experiment is disabled' do - let(:experiment_enabled) { false } + let(:learn_gitlab_enabled) { false } it 'returns false' do expect(subject.has_pill?).to eq false diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index c4fc50473a7..17c1adb9e2a 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -927,6 +927,8 @@ RSpec.describe ApplicationSetting do context 'throttle_* settings' do where(:throttle_setting) do %i[ + throttle_unauthenticated_api_requests_per_period + throttle_unauthenticated_api_period_in_seconds throttle_unauthenticated_requests_per_period throttle_unauthenticated_period_in_seconds throttle_authenticated_api_requests_per_period diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0b76dc3f87f..a7807852b74 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -4556,44 +4556,6 @@ RSpec.describe Project, factory_default: :keep do end end - describe '#legacy_remove_pages' do - let(:project) { create(:project).tap { |project| project.mark_pages_as_deployed } } - let(:pages_metadatum) { project.pages_metadatum } - let(:namespace) { project.namespace } - let(:pages_path) { project.pages_path } - - around do |example| - FileUtils.mkdir_p(pages_path) - begin - example.run - ensure - FileUtils.rm_rf(pages_path) - end - end - - it 'removes the pages directory and marks the project as not having pages deployed' do - expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project).and_return(true) - expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, namespace.full_path, anything) - - expect { project.legacy_remove_pages }.to change { pages_metadatum.reload.deployed }.from(true).to(false) - end - - it 'does nothing if updates on legacy storage are disabled' do - allow(Settings.pages.local_store).to receive(:enabled).and_return(false) - - expect(Gitlab::PagesTransfer).not_to receive(:new) - expect(PagesWorker).not_to receive(:perform_in) - - project.legacy_remove_pages - end - - it 'is run when the project is destroyed' do - expect(project).to receive(:legacy_remove_pages).and_call_original - - expect { project.destroy! }.not_to raise_error - end - end - describe '#remove_export' do let(:project) { create(:project, :with_export) } diff --git a/spec/requests/api/pages/pages_spec.rb b/spec/requests/api/pages/pages_spec.rb index f4c6de00e40..0eb2ae64f43 100644 --- a/spec/requests/api/pages/pages_spec.rb +++ b/spec/requests/api/pages/pages_spec.rb @@ -36,12 +36,7 @@ RSpec.describe API::Pages do end it 'removes the pages' do - expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project).and_return true - expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, project.namespace.full_path, anything) - - Sidekiq::Testing.inline! do - delete api("/projects/#{project.id}/pages", admin ) - end + delete api("/projects/#{project.id}/pages", admin ) expect(project.reload.pages_metadatum.deployed?).to be(false) end diff --git a/spec/services/application_settings/update_service_spec.rb b/spec/services/application_settings/update_service_spec.rb index a0c30620302..a1fd89bcad7 100644 --- a/spec/services/application_settings/update_service_spec.rb +++ b/spec/services/application_settings/update_service_spec.rb @@ -345,6 +345,9 @@ RSpec.describe ApplicationSettings::UpdateService do throttle_authenticated_web_enabled: true, throttle_authenticated_web_period_in_seconds: 30, throttle_authenticated_web_requests_per_period: 40, + throttle_unauthenticated_api_enabled: true, + throttle_unauthenticated_api_period_in_seconds: 50, + throttle_unauthenticated_api_requests_per_period: 60, throttle_unauthenticated_enabled: true, throttle_unauthenticated_period_in_seconds: 50, throttle_unauthenticated_requests_per_period: 60 diff --git a/spec/services/pages/delete_service_spec.rb b/spec/services/pages/delete_service_spec.rb index 295abe15bf0..e02e8e72e0b 100644 --- a/spec/services/pages/delete_service_spec.rb +++ b/spec/services/pages/delete_service_spec.rb @@ -12,27 +12,6 @@ RSpec.describe Pages::DeleteService do project.mark_pages_as_deployed end - it 'deletes published pages', :sidekiq_inline do - expect_next_instance_of(Gitlab::PagesTransfer) do |pages_transfer| - expect(pages_transfer).to receive(:rename_project).and_return true - end - - expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, project.namespace.full_path, anything) - - service.execute - end - - it "doesn't remove anything from the legacy storage if local_store is disabled", :sidekiq_inline do - allow(Settings.pages.local_store).to receive(:enabled).and_return(false) - - expect(project.pages_deployed?).to be(true) - expect(PagesWorker).not_to receive(:perform_in) - - service.execute - - expect(project.pages_deployed?).to be(false) - end - it 'marks pages as not deployed' do expect do service.execute diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb index 2a0c794cebb..6d0b75e0c95 100644 --- a/spec/services/projects/update_pages_service_spec.rb +++ b/spec/services/projects/update_pages_service_spec.rb @@ -18,10 +18,6 @@ RSpec.describe Projects::UpdatePagesService do subject { described_class.new(project, build) } - before do - project.legacy_remove_pages - end - context 'for new artifacts' do context "for a valid job" do let!(:artifacts_archive) { create(:ci_job_artifact, :correct_checksum, file: file, job: build) } diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb index 9a31d599808..adfe1cee6d6 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -68,8 +68,8 @@ RSpec.describe 'layouts/nav/sidebar/_project' do end describe 'Learn GitLab' do - it 'has a link to the learn GitLab experiment' do - allow(view).to receive(:learn_gitlab_experiment_enabled?).and_return(true) + it 'has a link to the learn GitLab' do + allow(view).to receive(:learn_gitlab_enabled?).and_return(true) allow_next_instance_of(LearnGitlab::Onboarding) do |onboarding| expect(onboarding).to receive(:completed_percentage).and_return(20) end diff --git a/spec/workers/namespaceless_project_destroy_worker_spec.rb b/spec/workers/namespaceless_project_destroy_worker_spec.rb index cd66af82364..93e8415f3bb 100644 --- a/spec/workers/namespaceless_project_destroy_worker_spec.rb +++ b/spec/workers/namespaceless_project_destroy_worker_spec.rb @@ -48,12 +48,6 @@ RSpec.describe NamespacelessProjectDestroyWorker do subject.perform(project.id) end - - it 'does not do anything in Project#legacy_remove_pages method' do - expect(Gitlab::PagesTransfer).not_to receive(:new) - - subject.perform(project.id) - end end context 'project forked from another' do diff --git a/spec/workers/pages_remove_worker_spec.rb b/spec/workers/pages_remove_worker_spec.rb index 864aa763fa9..9d49088b371 100644 --- a/spec/workers/pages_remove_worker_spec.rb +++ b/spec/workers/pages_remove_worker_spec.rb @@ -3,23 +3,9 @@ require 'spec_helper' RSpec.describe PagesRemoveWorker do - let(:project) { create(:project, path: "my.project")} - let!(:domain) { create(:pages_domain, project: project) } - - subject { described_class.new.perform(project.id) } - - before do - project.mark_pages_as_deployed - end - - it 'deletes published pages' do - expect(project.pages_deployed?).to be(true) - - expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project).and_return true - expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, project.namespace.full_path, anything) - - subject - - expect(project.reload.pages_deployed?).to be(false) + it 'does not raise error' do + expect do + described_class.new.perform(create(:project).id) + end.not_to raise_error end end |