diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-21 18:09:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-21 18:09:26 +0000 |
commit | 07d811cd3cf4d3a1802363532756bf69cfc6346f (patch) | |
tree | 4c0488ee52df65d58ba5c97a4e83bf1971469e34 /spec | |
parent | 71c6e099a8b019ab7749e43b63885d52de60e316 (diff) | |
download | gitlab-ce-07d811cd3cf4d3a1802363532756bf69cfc6346f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
35 files changed, 336 insertions, 158 deletions
diff --git a/spec/controllers/concerns/metrics_dashboard_spec.rb b/spec/controllers/concerns/metrics_dashboard_spec.rb index 83546403ce5..d68a9d70ec6 100644 --- a/spec/controllers/concerns/metrics_dashboard_spec.rb +++ b/spec/controllers/concerns/metrics_dashboard_spec.rb @@ -113,7 +113,7 @@ RSpec.describe MetricsDashboard do it 'includes project_blob_path only for project dashboards' do expect(system_dashboard['project_blob_path']).to be_nil - expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/-/blob/master/.gitlab/dashboards/test.yml") + expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.path}/-/blob/master/.gitlab/dashboards/test.yml") end it 'allows editing only for project dashboards' do diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index ea73f62981e..8caed2d3ac6 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -171,7 +171,7 @@ RSpec.describe Projects::ClustersController, feature_category: :deployment_manag { id: cluster.id, namespace_id: project.namespace.full_path, - project_id: project.name + project_id: project.path } end end diff --git a/spec/controllers/projects/environments/sample_metrics_controller_spec.rb b/spec/controllers/projects/environments/sample_metrics_controller_spec.rb index 14e3ded76f2..b266c569edd 100644 --- a/spec/controllers/projects/environments/sample_metrics_controller_spec.rb +++ b/spec/controllers/projects/environments/sample_metrics_controller_spec.rb @@ -46,7 +46,7 @@ RSpec.describe Projects::Environments::SampleMetricsController do { id: environment.id.to_s, namespace_id: project.namespace.full_path, - project_id: project.name, + project_id: project.path, identifier: 'sample_metric_query_result', start: '2019-12-02T23:31:45.000Z', end: '2019-12-03T00:01:45.000Z' diff --git a/spec/controllers/projects/grafana_api_controller_spec.rb b/spec/controllers/projects/grafana_api_controller_spec.rb index ae863918d14..c953ea02a15 100644 --- a/spec/controllers/projects/grafana_api_controller_spec.rb +++ b/spec/controllers/projects/grafana_api_controller_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Projects::GrafanaApiController, feature_category: :metrics do let(:params) do { namespace_id: project.namespace.full_path, - project_id: project.name, + project_id: project.path, proxy_path: 'api/v1/query_range', datasource_id: '1', query: 'rate(relevant_metric)', diff --git a/spec/controllers/projects/performance_monitoring/dashboards_controller_spec.rb b/spec/controllers/projects/performance_monitoring/dashboards_controller_spec.rb index 939366e5b0b..ca95d95a730 100644 --- a/spec/controllers/projects/performance_monitoring/dashboards_controller_spec.rb +++ b/spec/controllers/projects/performance_monitoring/dashboards_controller_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Projects::PerformanceMonitoring::DashboardsController do let_it_be(:user) { create(:user) } let_it_be(:namespace) { create(:namespace) } - let!(:project) { create(:project, :repository, name: 'dashboard-project', namespace: namespace) } + let_it_be(:project) { create(:project, :repository, namespace: namespace) } let(:repository) { project.repository } let(:branch) { double(name: branch_name) } let(:commit_message) { 'test' } @@ -120,7 +120,7 @@ RSpec.describe Projects::PerformanceMonitoring::DashboardsController do end context 'project without repository feature' do - let!(:project) { create(:project, name: 'dashboard-project', namespace: namespace) } + let_it_be(:project) { create(:project, namespace: namespace) } it 'responds with :not_found status code' do post :create, params: params @@ -246,7 +246,7 @@ RSpec.describe Projects::PerformanceMonitoring::DashboardsController do end context 'project without repository feature' do - let!(:project) { create(:project, name: 'dashboard-project', namespace: namespace) } + let_it_be(:project) { create(:project, namespace: namespace) } it 'responds with :not_found status code' do put :update, params: params diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 745e2dba967..69242b1532b 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -157,7 +157,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do expect(user_internal_regex['placeholder']).to eq 'Regex pattern' end - context 'Dormant users' do + context 'Dormant users', feature_category: :user_management do context 'when Gitlab.com' do let(:dot_com?) { true } diff --git a/spec/features/groups/packages_spec.rb b/spec/features/groups/packages_spec.rb index dd238657fbc..db069b194b5 100644 --- a/spec/features/groups/packages_spec.rb +++ b/spec/features/groups/packages_spec.rb @@ -37,7 +37,7 @@ RSpec.describe 'Group Packages', feature_category: :package_registry do end context 'when there are packages' do - let_it_be(:second_project) { create(:project, name: 'second-project', group: group) } + let_it_be(:second_project) { create(:project, group: group) } let_it_be(:npm_package) { create(:npm_package, project: project, name: 'zzz', created_at: 1.day.ago, version: '1.0.0') } let_it_be(:maven_package) { create(:maven_package, project: second_project, name: 'aaa', created_at: 2.days.ago, version: '2.0.0') } let_it_be(:packages) { [npm_package, maven_package] } @@ -50,10 +50,10 @@ RSpec.describe 'Group Packages', feature_category: :package_registry do it_behaves_like 'package details link' it 'allows you to navigate to the project page' do - find('[data-testid="root-link"]', text: project.name).click + find('[data-testid="root-link"]', text: project.path).click expect(page).to have_current_path(project_path(project)) - expect(page).to have_content(project.name) + expect(page).to have_content(project.path) end context 'sorting' do diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index f9e3ff1670c..74e5dc9f8c3 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -195,10 +195,11 @@ RSpec.describe 'File blob', :js, feature_category: :projects do end end - it 'successfully changes ref when the ref name matches the project name' do - project.repository.create_branch(project.name) + # Regression test for https://gitlab.com/gitlab-org/gitlab/-/issues/330947 + it 'successfully changes ref when the ref name matches the project path' do + project.repository.create_branch(project.path) - visit_blob('files/js/application.js', ref: project.name) + visit_blob('files/js/application.js', ref: project.path) switch_ref_to('master') aggregate_failures do diff --git a/spec/features/projects/settings/user_renames_a_project_spec.rb b/spec/features/projects/settings/user_renames_a_project_spec.rb index 2da6e760fbf..85d50083c33 100644 --- a/spec/features/projects/settings/user_renames_a_project_spec.rb +++ b/spec/features/projects/settings/user_renames_a_project_spec.rb @@ -67,7 +67,7 @@ RSpec.describe 'Projects > Settings > User renames a project', feature_category: end context 'when changing project path' do - let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') } + let(:project) { create(:project, :repository, namespace: user.namespace, path: 'gitlabhq') } before(:context) do TestEnv.clean_test_path diff --git a/spec/features/projects/work_items/work_item_spec.rb b/spec/features/projects/work_items/work_item_spec.rb index 94d0d155595..5f7163ed9af 100644 --- a/spec/features/projects/work_items/work_item_spec.rb +++ b/spec/features/projects/work_items/work_item_spec.rb @@ -20,9 +20,15 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do visit work_items_path end + it 'shows project issues link in breadcrumbs' do + within('[data-testid="breadcrumb-links"]') do + expect(page).to have_link('Issues', href: project_issues_path(project)) + end + end + it 'uses IID path in breadcrumbs' do within('[data-testid="breadcrumb-current-link"]') do - expect(page).to have_link('Work Items', href: work_items_path) + expect(page).to have_link("##{work_item.iid}", href: work_items_path) end end diff --git a/spec/frontend/jobs/components/log/log_spec.js b/spec/frontend/jobs/components/log/log_spec.js index 265f72ff344..20638b13169 100644 --- a/spec/frontend/jobs/components/log/log_spec.js +++ b/spec/frontend/jobs/components/log/log_spec.js @@ -1,11 +1,18 @@ import { mount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; +import waitForPromises from 'helpers/wait_for_promises'; +import { scrollToElement } from '~/lib/utils/common_utils'; import Log from '~/jobs/components/log/log.vue'; import LogLineHeader from '~/jobs/components/log/line_header.vue'; import { logLinesParser } from '~/jobs/store/utils'; import { jobLog } from './mock_data'; +jest.mock('~/lib/utils/common_utils', () => ({ + ...jest.requireActual('~/lib/utils/common_utils'), + scrollToElement: jest.fn(), +})); + describe('Job Log', () => { let wrapper; let actions; @@ -36,13 +43,15 @@ describe('Job Log', () => { actions, state, }); - - createComponent(); }); const findCollapsibleLine = () => wrapper.findComponent(LogLineHeader); describe('line numbers', () => { + beforeEach(() => { + createComponent(); + }); + it('renders a line number for each open line', () => { expect(wrapper.find('#L1').text()).toBe('1'); expect(wrapper.find('#L2').text()).toBe('2'); @@ -55,6 +64,10 @@ describe('Job Log', () => { }); describe('collapsible sections', () => { + beforeEach(() => { + createComponent(); + }); + it('renders a clickable header section', () => { expect(findCollapsibleLine().attributes('role')).toBe('button'); }); @@ -73,4 +86,49 @@ describe('Job Log', () => { }); }); }); + + describe('anchor scrolling', () => { + afterEach(() => { + window.location.hash = ''; + }); + + describe('when hash is not present', () => { + it('does not scroll to line number', async () => { + createComponent(); + + await waitForPromises(); + + expect(wrapper.find('#L6').exists()).toBe(false); + expect(scrollToElement).not.toHaveBeenCalled(); + }); + }); + + describe('when hash is present', () => { + beforeEach(() => { + window.location.hash = '#L6'; + }); + + it('scrolls to line number', async () => { + createComponent(); + + state.jobLog = logLinesParser(jobLog, [], '#L6'); + await waitForPromises(); + + expect(scrollToElement).toHaveBeenCalledTimes(1); + + state.jobLog = logLinesParser(jobLog, [], '#L7'); + await waitForPromises(); + + expect(scrollToElement).toHaveBeenCalledTimes(1); + }); + + it('line number within collapsed section is visible', () => { + state.jobLog = logLinesParser(jobLog, [], '#L6'); + + createComponent(); + + expect(wrapper.find('#L6').exists()).toBe(true); + }); + }); + }); }); diff --git a/spec/frontend/jobs/components/log/mock_data.js b/spec/frontend/jobs/components/log/mock_data.js index eb8c4fe8bc9..fa51b92a044 100644 --- a/spec/frontend/jobs/components/log/mock_data.js +++ b/spec/frontend/jobs/components/log/mock_data.js @@ -22,6 +22,30 @@ export const jobLog = [ content: [{ text: 'Starting service postgres:9.6.14 ...', style: 'text-green' }], section: 'prepare-executor', }, + { + offset: 1004, + content: [ + { + text: 'Restore cache', + style: 'term-fg-l-cyan term-bold', + }, + ], + section: 'restore-cache', + section_header: true, + section_options: { + collapsed: 'true', + }, + }, + { + offset: 1005, + content: [ + { + text: 'Checking cache for ruby-gems-debian-bullseye-ruby-3.0-16...', + style: 'term-fg-l-green term-bold', + }, + ], + section: 'restore-cache', + }, ]; export const utilsMockData = [ diff --git a/spec/frontend/jobs/components/table/job_table_app_spec.js b/spec/frontend/jobs/components/table/job_table_app_spec.js index 19033c227d9..1ca28fefd28 100644 --- a/spec/frontend/jobs/components/table/job_table_app_spec.js +++ b/spec/frontend/jobs/components/table/job_table_app_spec.js @@ -1,10 +1,4 @@ -import { - GlSkeletonLoader, - GlAlert, - GlEmptyState, - GlIntersectionObserver, - GlLoadingIcon, -} from '@gitlab/ui'; +import { GlAlert, GlEmptyState, GlIntersectionObserver, GlLoadingIcon } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; @@ -19,6 +13,7 @@ import JobsTable from '~/jobs/components/table/jobs_table.vue'; import JobsTableApp from '~/jobs/components/table/jobs_table_app.vue'; import JobsTableTabs from '~/jobs/components/table/jobs_table_tabs.vue'; import JobsFilteredSearch from '~/jobs/components/filtered_search/jobs_filtered_search.vue'; +import JobsSkeletonLoader from '~/pages/admin/jobs/components/jobs_skeleton_loader.vue'; import * as urlUtils from '~/lib/utils/url_utility'; import { mockJobsResponsePaginated, @@ -41,7 +36,7 @@ describe('Job table app', () => { const countSuccessHandler = jest.fn().mockResolvedValue(mockJobsCountResponse); - const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); + const findSkeletonLoader = () => wrapper.findComponent(JobsSkeletonLoader); const findLoadingSpinner = () => wrapper.findComponent(GlLoadingIcon); const findTable = () => wrapper.findComponent(JobsTable); const findTabs = () => wrapper.findComponent(JobsTableTabs); diff --git a/spec/frontend/jobs/store/utils_spec.js b/spec/frontend/jobs/store/utils_spec.js index 9458c2184f5..37a6722c555 100644 --- a/spec/frontend/jobs/store/utils_spec.js +++ b/spec/frontend/jobs/store/utils_spec.js @@ -43,6 +43,14 @@ describe('Jobs Store Utils', () => { expect(parsedHeaderLine.isClosed).toBe(true); }); + + it('expands all pre-closed sections if hash is present', () => { + const headerLine = { content: [{ text: 'foo' }], section_options: { collapsed: 'true' } }; + + const parsedHeaderLine = parseHeaderLine(headerLine, 2, '#L33'); + + expect(parsedHeaderLine.isClosed).toBe(false); + }); }); describe('parseLine', () => { diff --git a/spec/frontend/pages/admin/jobs/components/jobs_skeleton_loader_spec.js b/spec/frontend/pages/admin/jobs/components/jobs_skeleton_loader_spec.js new file mode 100644 index 00000000000..03e5cd75420 --- /dev/null +++ b/spec/frontend/pages/admin/jobs/components/jobs_skeleton_loader_spec.js @@ -0,0 +1,28 @@ +import { GlSkeletonLoader } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import JobsSkeletonLoader from '~/pages/admin/jobs/components/jobs_skeleton_loader.vue'; + +describe('jobs_skeleton_loader.vue', () => { + let wrapper; + + const findGlSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); + + const WIDTH = '1248'; + const HEIGHT = '73'; + + beforeEach(() => { + wrapper = shallowMount(JobsSkeletonLoader); + }); + + it('renders a GlSkeletonLoader', () => { + expect(findGlSkeletonLoader().exists()).toBe(true); + }); + + it('has correct width', () => { + expect(findGlSkeletonLoader().attributes('width')).toBe(WIDTH); + }); + + it('has correct height', () => { + expect(findGlSkeletonLoader().attributes('height')).toBe(HEIGHT); + }); +}); diff --git a/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js b/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js index 8dabc076980..df55c737e3f 100644 --- a/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js +++ b/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js @@ -1,4 +1,4 @@ -import { GlSkeletonLoader, GlLoadingIcon, GlEmptyState, GlAlert } from '@gitlab/ui'; +import { GlLoadingIcon, GlEmptyState, GlAlert } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; @@ -7,6 +7,8 @@ import waitForPromises from 'helpers/wait_for_promises'; import JobsTable from '~/jobs/components/table/jobs_table.vue'; import getJobsQuery from '~/pages/admin/jobs/components/table/graphql/queries/get_all_jobs.query.graphql'; import AdminJobsTableApp from '~/pages/admin/jobs/components/table/admin_jobs_table_app.vue'; +import JobsTableTabs from '~/jobs/components/table/jobs_table_tabs.vue'; +import JobsSkeletonLoader from '~/pages/admin/jobs/components/jobs_skeleton_loader.vue'; import { mockAllJobsResponsePaginated, @@ -23,11 +25,12 @@ describe('Job table app', () => { const emptyHandler = jest.fn().mockResolvedValue(mockJobsResponseEmpty); const failedHandler = jest.fn().mockRejectedValue(new Error('GraphQL error')); - const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); + const findSkeletonLoader = () => wrapper.findComponent(JobsSkeletonLoader); const findLoadingSpinner = () => wrapper.findComponent(GlLoadingIcon); const findTable = () => wrapper.findComponent(JobsTable); const findEmptyState = () => wrapper.findComponent(GlEmptyState); const findAlert = () => wrapper.findComponent(GlAlert); + const findTabs = () => wrapper.findComponent(JobsTableTabs); const createMockApolloProvider = (handler) => { const requestHandlers = [[getJobsQuery, handler]]; @@ -53,6 +56,25 @@ describe('Job table app', () => { }); }; + describe('loading state', () => { + it('should display skeleton loader when loading', () => { + createComponent(); + + expect(findSkeletonLoader().exists()).toBe(true); + expect(findTable().exists()).toBe(false); + expect(findLoadingSpinner().exists()).toBe(false); + }); + + it('when switching tabs only the skeleton loader should show', () => { + createComponent(); + + findTabs().vm.$emit('fetchJobsByStatus', null); + + expect(findSkeletonLoader().exists()).toBe(true); + expect(findLoadingSpinner().exists()).toBe(false); + }); + }); + describe('loaded state', () => { beforeEach(async () => { createComponent(); diff --git a/spec/frontend/set_status_modal/set_status_modal_wrapper_spec.js b/spec/frontend/set_status_modal/set_status_modal_wrapper_spec.js index b5bf739b35a..60267cf31be 100644 --- a/spec/frontend/set_status_modal/set_status_modal_wrapper_spec.js +++ b/spec/frontend/set_status_modal/set_status_modal_wrapper_spec.js @@ -1,5 +1,6 @@ import { GlModal, GlFormCheckbox } from '@gitlab/ui'; import { nextTick } from 'vue'; +import { createWrapper } from '@vue/test-utils'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import { useFakeDate } from 'helpers/fake_date'; import { initEmojiMock, clearEmojiMock } from 'helpers/emoji'; @@ -10,13 +11,17 @@ import stubChildren from 'helpers/stub_children'; import SetStatusModalWrapper from '~/set_status_modal/set_status_modal_wrapper.vue'; import { AVAILABILITY_STATUS } from '~/set_status_modal/constants'; import SetStatusForm from '~/set_status_modal/set_status_form.vue'; +import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; +import { BV_HIDE_MODAL } from '~/lib/utils/constants'; jest.mock('~/alert'); describe('SetStatusModalWrapper', () => { let wrapper; + const mockToastShow = jest.fn(); + const $toast = { - show: jest.fn(), + show: mockToastShow, }; const defaultEmoji = 'speech_balloon'; @@ -58,18 +63,7 @@ describe('SetStatusModalWrapper', () => { const findClearStatusButton = () => wrapper.find('.js-clear-user-status-button'); const findAvailabilityCheckbox = () => wrapper.findComponent(GlFormCheckbox); const getEmojiPicker = () => wrapper.findComponent(EmojiPickerStub); - - const initModal = async ({ mockOnUpdateSuccess = true, mockOnUpdateFailure = true } = {}) => { - const modal = findModal(); - // mock internal emoji methods - wrapper.vm.showEmojiMenu = jest.fn(); - wrapper.vm.hideEmojiMenu = jest.fn(); - if (mockOnUpdateSuccess) wrapper.vm.onUpdateSuccess = jest.fn(); - if (mockOnUpdateFailure) wrapper.vm.onUpdateFail = jest.fn(); - - modal.vm.$emit('shown'); - await nextTick(); - }; + const initModal = () => findModal().vm.$emit('shown'); afterEach(() => { clearEmojiMock(); @@ -148,6 +142,8 @@ describe('SetStatusModalWrapper', () => { describe('update status', () => { describe('succeeds', () => { + useMockLocationHelper(); + beforeEach(async () => { await initEmojiMock(); wrapper = createComponent(); @@ -194,11 +190,21 @@ describe('SetStatusModalWrapper', () => { }); }); - it('calls the "onUpdateSuccess" handler', async () => { + it('displays a toast message and reloads window', async () => { + findModal().vm.$emit('primary'); + await nextTick(); + + expect(mockToastShow).toHaveBeenCalledWith('Status updated'); + expect(window.location.reload).toHaveBeenCalled(); + }); + + it('closes modal', async () => { + const rootWrapper = createWrapper(wrapper.vm.$root); + findModal().vm.$emit('primary'); await nextTick(); - expect(wrapper.vm.onUpdateSuccess).toHaveBeenCalled(); + expect(rootWrapper.emitted(BV_HIDE_MODAL)).toEqual([['set-user-status-modal']]); }); }); @@ -227,11 +233,22 @@ describe('SetStatusModalWrapper', () => { jest.spyOn(UserApi, 'updateUserStatus').mockRejectedValue(); }); - it('calls the "onUpdateFail" handler', async () => { + it('displays an error alert', async () => { + findModal().vm.$emit('primary'); + await nextTick(); + + expect(createAlert).toHaveBeenCalledWith({ + message: "Sorry, we weren't able to set your status. Please try again later.", + }); + }); + + it('closes modal', async () => { + const rootWrapper = createWrapper(wrapper.vm.$root); + findModal().vm.$emit('primary'); await nextTick(); - expect(wrapper.vm.onUpdateFail).toHaveBeenCalled(); + expect(rootWrapper.emitted(BV_HIDE_MODAL)).toEqual([['set-user-status-modal']]); }); }); diff --git a/spec/frontend/super_sidebar/components/frequent_items_list_spec.js b/spec/frontend/super_sidebar/components/frequent_items_list_spec.js index 86cec3f3d13..5329a8f5da3 100644 --- a/spec/frontend/super_sidebar/components/frequent_items_list_spec.js +++ b/spec/frontend/super_sidebar/components/frequent_items_list_spec.js @@ -1,4 +1,3 @@ -import { GlIcon, GlButton } from '@gitlab/ui'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { s__ } from '~/locale'; import FrequentItemsList from '~/super_sidebar/components//frequent_items_list.vue'; @@ -17,7 +16,6 @@ describe('FrequentItemsList component', () => { let wrapper; const findListTitle = () => wrapper.findByTestId('list-title'); - const findListEditButton = () => findListTitle().findComponent(GlButton); const findItemsList = () => wrapper.findComponent(ItemsList); const findEmptyText = () => wrapper.findByTestId('empty-text'); @@ -68,30 +66,8 @@ describe('FrequentItemsList component', () => { }); describe('items editing', () => { - it('renders edit button within header', () => { - const itemsEditButton = findListEditButton(); - - expect(itemsEditButton.exists()).toBe(true); - expect(itemsEditButton.attributes('title')).toBe('Toggle edit mode'); - expect(itemsEditButton.findComponent(GlIcon).props('name')).toBe('pencil'); - }); - - it('clicking edit button makes items list editable', async () => { - // Off by default - expect(findItemsList().props('editable')).toBe(false); - - // On when clicked - await findListEditButton().vm.$emit('click'); - expect(findItemsList().props('editable')).toBe(true); - - // Off when clicked again - await findListEditButton().vm.$emit('click'); - expect(findItemsList().props('editable')).toBe(false); - }); - it('remove-item event emission from items-list causes list item to be removed', async () => { const localStorageProjects = findItemsList().props('items'); - await findListEditButton().vm.$emit('click'); await findItemsList().vm.$emit('remove-item', localStorageProjects[0]); diff --git a/spec/frontend/super_sidebar/components/help_center_spec.js b/spec/frontend/super_sidebar/components/help_center_spec.js index 4c0e7a89a43..aa94ca301db 100644 --- a/spec/frontend/super_sidebar/components/help_center_spec.js +++ b/spec/frontend/super_sidebar/components/help_center_spec.js @@ -42,45 +42,47 @@ describe('HelpCenter component', () => { }; }; + const DEFAULT_HELP_ITEMS = [ + { text: HelpCenter.i18n.help, href: helpPagePath(), extraAttrs: trackingAttrs('help') }, + { + text: HelpCenter.i18n.support, + href: sidebarData.support_path, + extraAttrs: trackingAttrs('support'), + }, + { + text: HelpCenter.i18n.docs, + href: 'https://docs.gitlab.com', + extraAttrs: trackingAttrs('gitlab_documentation'), + }, + { + text: HelpCenter.i18n.plans, + href: `${PROMO_URL}/pricing`, + extraAttrs: trackingAttrs('compare_gitlab_plans'), + }, + { + text: HelpCenter.i18n.forum, + href: 'https://forum.gitlab.com/', + extraAttrs: trackingAttrs('community_forum'), + }, + { + text: HelpCenter.i18n.contribute, + href: helpPagePath('', { anchor: 'contributing-to-gitlab' }), + extraAttrs: trackingAttrs('contribute_to_gitlab'), + }, + { + text: HelpCenter.i18n.feedback, + href: 'https://about.gitlab.com/submit-feedback', + extraAttrs: trackingAttrs('submit_feedback'), + }, + ]; + describe('default', () => { beforeEach(() => { createWrapper(sidebarData); }); it('renders menu items', () => { - expect(findDropdownGroup(0).props('group').items).toEqual([ - { text: HelpCenter.i18n.help, href: helpPagePath(), extraAttrs: trackingAttrs('help') }, - { - text: HelpCenter.i18n.support, - href: sidebarData.support_path, - extraAttrs: trackingAttrs('support'), - }, - { - text: HelpCenter.i18n.docs, - href: 'https://docs.gitlab.com', - extraAttrs: trackingAttrs('gitlab_documentation'), - }, - { - text: HelpCenter.i18n.plans, - href: `${PROMO_URL}/pricing`, - extraAttrs: trackingAttrs('compare_gitlab_plans'), - }, - { - text: HelpCenter.i18n.forum, - href: 'https://forum.gitlab.com/', - extraAttrs: trackingAttrs('community_forum'), - }, - { - text: HelpCenter.i18n.contribute, - href: helpPagePath('', { anchor: 'contributing-to-gitlab' }), - extraAttrs: trackingAttrs('contribute_to_gitlab'), - }, - { - text: HelpCenter.i18n.feedback, - href: 'https://about.gitlab.com/submit-feedback', - extraAttrs: trackingAttrs('submit_feedback'), - }, - ]); + expect(findDropdownGroup(0).props('group').items).toEqual(DEFAULT_HELP_ITEMS); expect(findDropdownGroup(1).props('group').items).toEqual([ expect.objectContaining({ text: HelpCenter.i18n.shortcuts }), @@ -94,6 +96,23 @@ describe('HelpCenter component', () => { }); }); + describe('with show_tanuki_bot true', () => { + beforeEach(() => { + createWrapper({ ...sidebarData, show_tanuki_bot: true }); + }); + + it('shows Ask the Tanuki Bot with the help items', () => { + expect(findDropdownGroup(0).props('group').items).toEqual([ + expect.objectContaining({ + icon: 'tanuki', + text: HelpCenter.i18n.tanuki, + extraAttrs: trackingAttrs('tanuki_bot_help_dropdown'), + }), + ...DEFAULT_HELP_ITEMS, + ]); + }); + }); + describe('with Gitlab version check feature enabled', () => { beforeEach(() => { createWrapper({ ...sidebarData, show_version_check: true }); diff --git a/spec/frontend/super_sidebar/components/items_list_spec.js b/spec/frontend/super_sidebar/components/items_list_spec.js index d49ef35e9d8..d5e8043cce9 100644 --- a/spec/frontend/super_sidebar/components/items_list_spec.js +++ b/spec/frontend/super_sidebar/components/items_list_spec.js @@ -73,7 +73,6 @@ describe('ItemsList component', () => { createWrapper({ props: { items: [mockProject], - editable: true, }, mountFn: mountExtended, }); @@ -84,7 +83,7 @@ describe('ItemsList component', () => { expect(itemRemoveButton.exists()).toBe(true); expect(itemRemoveButton.attributes('title')).toBe('Remove'); - expect(itemRemoveButton.findComponent(GlIcon).props('name')).toBe('close'); + expect(itemRemoveButton.findComponent(GlIcon).props('name')).toBe('dash'); }); it('emits `remove-item` event with item param when remove button is clicked', () => { diff --git a/spec/lib/banzai/pipeline/incident_management/timeline_event_pipeline_spec.rb b/spec/lib/banzai/pipeline/incident_management/timeline_event_pipeline_spec.rb index 8d15dbc8f2f..12a6be6bc18 100644 --- a/spec/lib/banzai/pipeline/incident_management/timeline_event_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/incident_management/timeline_event_pipeline_spec.rb @@ -78,7 +78,7 @@ RSpec.describe Banzai::Pipeline::IncidentManagement::TimelineEventPipeline do it 'replaces existing label to a link' do # rubocop:disable Layout/LineLength is_expected.to match( - %r(<p>.+<a href="[\w/]+-/issues\?label_name=#{label.name}".+style="background-color: #\d{6}".*>#{label.name}</span></a></span> ~unknown</p>) + %r{<p>.+<a href="[\w\-/]+-/issues\?label_name=#{label.name}".+style="background-color: #\d{6}".*>#{label.name}</span></a></span> ~unknown</p>} ) # rubocop:enable Layout/LineLength end @@ -95,7 +95,7 @@ RSpec.describe Banzai::Pipeline::IncidentManagement::TimelineEventPipeline do let(:markdown) { "issue ##{issue.iid}" } it 'contains a link to the issue' do - is_expected.to match(%r(<p>issue <a href="[\w/]+-/issues/#{issue.iid}".*>##{issue.iid}</a></p>)) + is_expected.to match(%r{<p>issue <a href="[\w\-/]+-/issues/#{issue.iid}".*>##{issue.iid}</a></p>}) end end @@ -104,7 +104,7 @@ RSpec.describe Banzai::Pipeline::IncidentManagement::TimelineEventPipeline do let(:markdown) { "MR !#{mr.iid}" } it 'contains a link to the merge request' do - is_expected.to match(%r(<p>MR <a href="[\w/]+-/merge_requests/#{mr.iid}".*>!#{mr.iid}</a></p>)) + is_expected.to match(%r{<p>MR <a href="[\w\-/]+-/merge_requests/#{mr.iid}".*>!#{mr.iid}</a></p>}) end end end diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb index 837ea2d7bc0..81406eae0c9 100644 --- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do - let_it_be(:namespace) { create(:namespace, name: "wiki_link_ns") } - let_it_be(:project) { create(:project, :public, name: "wiki_link_project", namespace: namespace) } + let_it_be(:namespace) { create(:namespace) } + let_it_be(:project) { create(:project, :public, namespace: namespace) } let_it_be(:wiki) { ProjectWiki.new(project, nil) } let_it_be(:page) { build(:wiki_page, wiki: wiki, title: 'nested/twice/start-page') } @@ -85,14 +85,14 @@ RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do markdown = "[Page](./page)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/page\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/nested/twice/page\"") end it "rewrites file links to be at the scope of the current directory" do markdown = "[Link to Page](./page.md)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/nested/twice/page.md\"") end end @@ -101,14 +101,14 @@ RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do markdown = "[Link to Page](../page)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/page\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/nested/page\"") end it "rewrites file links to be at the scope of the parent directory" do markdown = "[Link to Page](../page.md)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/nested/page.md\"") end end @@ -117,14 +117,14 @@ RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do markdown = "[Link to Page](./subdirectory/page)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/subdirectory/page\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/nested/twice/subdirectory/page\"") end it "rewrites file links to be at the scope of the sub-directory" do markdown = "[Link to Page](./subdirectory/page.md)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/subdirectory/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/nested/twice/subdirectory/page.md\"") end end @@ -133,35 +133,35 @@ RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do markdown = "[Link to Page](page)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/page\"") end it 'rewrites non-file links (with spaces) to be at the scope of the wiki root' do markdown = "[Link to Page](page slug)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page%20slug\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/page%20slug\"") end it "rewrites file links to be at the scope of the current directory" do markdown = "[Link to Page](page.md)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/nested/twice/page.md\"") end it 'rewrites links with anchor' do markdown = '[Link to Header](start-page#title)' output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/start-page#title\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/start-page#title\"") end it 'rewrites links (with spaces) with anchor' do markdown = '[Link to Header](start page#title)' output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/start%20page#title\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/start%20page#title\"") end end @@ -170,14 +170,14 @@ RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do markdown = "[Link to Page](/page)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/page\"") end it 'rewrites file links to be at the scope of the wiki root' do markdown = "[Link to Page](/page.md)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/-/wikis/page.md\"") + expect(output).to include("href=\"#{relative_url_root}/#{project.full_path}/-/wikis/page.md\"") end end end @@ -278,28 +278,28 @@ RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do markdown = "![video_file](video_file_name.mp4)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include('<video src="/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/video_file_name.mp4"') + expect(output).to include(%(<video src="/#{project.full_path}/-/wikis/nested/twice/video_file_name.mp4")) end it 'rewrites and replaces video links names with white spaces to %20' do markdown = "![video file](video file name.mp4)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include('<video src="/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/video%20file%20name.mp4"') + expect(output).to include(%(<video src="/#{project.full_path}/-/wikis/nested/twice/video%20file%20name.mp4")) end it 'generates audio html structure' do markdown = "![audio_file](audio_file_name.wav)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include('<audio src="/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/audio_file_name.wav"') + expect(output).to include(%(<audio src="/#{project.full_path}/-/wikis/nested/twice/audio_file_name.wav")) end it 'rewrites and replaces audio links names with white spaces to %20' do markdown = "![audio file](audio file name.wav)" output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) - expect(output).to include('<audio src="/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/audio%20file%20name.wav"') + expect(output).to include(%(<audio src="/#{project.full_path}/-/wikis/nested/twice/audio%20file%20name.wav")) end end @@ -320,7 +320,7 @@ RSpec.describe Banzai::Pipeline::WikiPipeline, feature_category: :wiki do output = described_class.to_html(markdown, project: project, wiki: wiki, page_slug: page.slug) doc = Nokogiri::HTML::DocumentFragment.parse(output) - full_path = "/wiki_link_ns/wiki_link_project/-/wikis/nested/twice/#{wiki_file.path}" + full_path = "/#{project.full_path}/-/wikis/nested/twice/#{wiki_file.path}" expect(doc.css('a')[0].attr('href')).to eq(full_path) expect(doc.css('img')[0].attr('class')).to eq('gfm lazy') expect(doc.css('img')[0].attr('data-src')).to eq(full_path) diff --git a/spec/lib/container_registry/gitlab_api_client_spec.rb b/spec/lib/container_registry/gitlab_api_client_spec.rb index 73364ec9698..ac15048e4b5 100644 --- a/spec/lib/container_registry/gitlab_api_client_spec.rb +++ b/spec/lib/container_registry/gitlab_api_client_spec.rb @@ -552,7 +552,7 @@ RSpec.describe ContainerRegistry::GitlabApiClient do end let_it_be(:group) { create(:group, path: 'build') } - let_it_be(:project) { create(:project, name: 'cng', namespace: group) } + let_it_be(:project) { create(:project, path: 'cng', namespace: group) } let_it_be(:container_repository) { create(:container_repository, project: project, name: "docker-alpine") } shared_examples 'fetching the project from container repository and path' do diff --git a/spec/lib/gitlab/ci/config/external/file/project_spec.rb b/spec/lib/gitlab/ci/config/external/file/project_spec.rb index 59522e7ab7d..947d8ebc698 100644 --- a/spec/lib/gitlab/ci/config/external/file/project_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/project_spec.rb @@ -260,16 +260,16 @@ RSpec.describe Gitlab::Ci::Config::External::File::Project, feature_category: :p } context 'when project name and ref include masked variables' do - let(:project_name) { 'my_project_name' } + let_it_be(:project) { create(:project, :repository, path: 'my_project_path') } + let(:branch_name) { 'merge-commit-analyze-after' } - let(:project) { create(:project, :repository, name: project_name) } let(:namespace_path) { project.namespace.full_path } let(:included_project_sha) { project.commit(branch_name).sha } let(:variables) do Gitlab::Ci::Variables::Collection.new( [ - { key: 'VAR1', value: project_name, masked: true }, + { key: 'VAR1', value: 'my_project_path', masked: true }, { key: 'VAR2', value: branch_name, masked: true } ]) end diff --git a/spec/lib/gitlab/metrics/dashboard/stages/grafana_formatter_spec.rb b/spec/lib/gitlab/metrics/dashboard/stages/grafana_formatter_spec.rb index 8a236f72a60..3cfdfafb0c5 100644 --- a/spec/lib/gitlab/metrics/dashboard/stages/grafana_formatter_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/stages/grafana_formatter_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe Gitlab::Metrics::Dashboard::Stages::GrafanaFormatter do include GrafanaApiHelpers - let_it_be(:namespace) { create(:namespace, name: 'foo') } - let_it_be(:project) { create(:project, namespace: namespace, name: 'bar') } + let_it_be(:namespace) { create(:namespace, path: 'foo') } + let_it_be(:project) { create(:project, namespace: namespace, path: 'bar') } describe '#transform!' do let(:grafana_dashboard) { Gitlab::Json.parse(fixture_file('grafana/simplified_dashboard_response.json'), symbolize_names: true) } diff --git a/spec/lib/gitlab/tracking/destinations/database_events_snowplow_spec.rb b/spec/lib/gitlab/tracking/destinations/database_events_snowplow_spec.rb index 0f2082c1f25..78a869b535a 100644 --- a/spec/lib/gitlab/tracking/destinations/database_events_snowplow_spec.rb +++ b/spec/lib/gitlab/tracking/destinations/database_events_snowplow_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Gitlab::Tracking::Destinations::DatabaseEventsSnowplow, :do_not_s before do allow(SnowplowTracker::AsyncEmitter) .to receive(:new) - .with(endpoint: 'localhost:9091', + .with(endpoint: endpoint, options: { protocol: 'https', @@ -47,15 +47,38 @@ RSpec.describe Gitlab::Tracking::Destinations::DatabaseEventsSnowplow, :do_not_s end describe '#event' do + let(:endpoint) { 'localhost:9091' } + let(:event_params) do + { + category: 'category', + action: 'action', + label: 'label', + property: 'property', + value: 1.5, + context: nil, + tstamp: (Time.now.to_f * 1000).to_i + } + end + + context 'when on gitlab.com environment' do + let(:endpoint) { 'db-snowplow.trx.gitlab.net' } + + it 'sends event to tracker' do + allow(Gitlab).to receive(:com?).and_return(true) + allow(tracker).to receive(:track_struct_event).and_call_original + + subject.event('category', 'action', label: 'label', property: 'property', value: 1.5) + + expect(tracker).to have_received(:track_struct_event).with(event_params) + end + end + it 'sends event to tracker' do allow(tracker).to receive(:track_struct_event).and_call_original subject.event('category', 'action', label: 'label', property: 'property', value: 1.5) - expect(tracker) - .to have_received(:track_struct_event) - .with(category: 'category', action: 'action', label: 'label', property: 'property', value: 1.5, context: nil, - tstamp: (Time.now.to_f * 1000).to_i) + expect(tracker).to have_received(:track_struct_event).with(event_params) end it 'increase total snowplow events counter' do diff --git a/spec/models/container_registry/event_spec.rb b/spec/models/container_registry/event_spec.rb index edec5afaddb..d5c3a5fc066 100644 --- a/spec/models/container_registry/event_spec.rb +++ b/spec/models/container_registry/event_spec.rb @@ -6,7 +6,7 @@ RSpec.describe ContainerRegistry::Event do using RSpec::Parameterized::TableSyntax let_it_be(:group) { create(:group, name: 'group') } - let_it_be(:project) { create(:project, name: 'test', namespace: group) } + let_it_be(:project) { create(:project, path: 'test', namespace: group) } describe '#supported?' do let(:raw_event) { { 'action' => action } } diff --git a/spec/models/releases/source_spec.rb b/spec/models/releases/source_spec.rb index 227085951c0..fadc2fd6f53 100644 --- a/spec/models/releases/source_spec.rb +++ b/spec/models/releases/source_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Releases::Source do - let_it_be(:project) { create(:project, :repository, name: 'finance-cal') } + let_it_be(:project) { create(:project, :repository) } let(:tag_name) { 'v1.0' } @@ -27,7 +27,7 @@ RSpec.describe Releases::Source do it 'returns zip archived source url' do is_expected - .to eq("#{project.web_url}/-/archive/v1.0/finance-cal-v1.0.zip") + .to eq("#{project.web_url}/-/archive/v1.0/#{project.path}-v1.0.zip") end context 'when ref is directory structure' do @@ -35,7 +35,7 @@ RSpec.describe Releases::Source do it 'converts slash to dash' do is_expected - .to eq("#{project.web_url}/-/archive/beta/v1.0/finance-cal-beta-v1.0.zip") + .to eq("#{project.web_url}/-/archive/beta/v1.0/#{project.path}-beta-v1.0.zip") end end end diff --git a/spec/presenters/issue_presenter_spec.rb b/spec/presenters/issue_presenter_spec.rb index e11ecd5bf6c..f9a3be9bbed 100644 --- a/spec/presenters/issue_presenter_spec.rb +++ b/spec/presenters/issue_presenter_spec.rb @@ -29,7 +29,7 @@ RSpec.describe IssuePresenter do describe '#web_url' do it 'returns correct path' do - expect(presenter.web_url).to eq("http://localhost/#{group.name}/#{project.name}/-/issues/#{presented_issue.iid}") + expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/-/issues/#{presented_issue.iid}") end context 'when issue type is task' do @@ -59,7 +59,7 @@ RSpec.describe IssuePresenter do describe '#issue_path' do it 'returns correct path' do - expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{presented_issue.iid}") + expect(presenter.issue_path).to eq("/#{project.full_path}/-/issues/#{presented_issue.iid}") end context 'when issue type is task' do diff --git a/spec/presenters/releases/link_presenter_spec.rb b/spec/presenters/releases/link_presenter_spec.rb index e52c68ffb38..79cfab0bc0a 100644 --- a/spec/presenters/releases/link_presenter_spec.rb +++ b/spec/presenters/releases/link_presenter_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Releases::LinkPresenter do context 'when filepath is provided' do let(:filepath) { '/bin/bigfile.exe' } let(:expected_url) do - "http://localhost/#{release.project.namespace.path}/#{release.project.name}" \ + "http://localhost/#{release.project.full_path}" \ "/-/releases/#{release.tag}/downloads/bin/bigfile.exe" end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index bf30052069d..49bfdf053ef 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -951,7 +951,7 @@ RSpec.describe API::Projects, :aggregate_failures, feature_category: :projects d expect(json_response.length).to eq(8) project_names = json_response.map { |proj| proj['name'] } - expect(project_names).to contain_exactly(project.name, project2.name, 'second_project', 'public_project', 'Project', 'Test Project', 'Test Public Project', 'Test') + expect(project_names).to match_array([project, project2, project3, public_project, project_1, project_2, project_4, project_3].map(&:name)) end end diff --git a/spec/serializers/analytics_issue_entity_spec.rb b/spec/serializers/analytics_issue_entity_spec.rb index ca1e0705d77..e86c0d9d883 100644 --- a/spec/serializers/analytics_issue_entity_spec.rb +++ b/spec/serializers/analytics_issue_entity_spec.rb @@ -72,7 +72,7 @@ RSpec.describe AnalyticsIssueEntity do end context 'without subgroup' do - let_it_be(:project) { create(:project, name: 'my project') } + let_it_be(:project) { create(:project) } subject { entity.as_json } @@ -80,14 +80,14 @@ RSpec.describe AnalyticsIssueEntity do end context 'with subgroup' do - let_it_be(:project) { create(:project, :in_subgroup, name: 'my project') } + let_it_be(:project) { create(:project, :in_subgroup) } subject { entity.as_json } it_behaves_like 'generic entity' it 'has URL containing subgroup' do - expect(subject[:url]).to include("#{project.group.parent.name}/#{project.group.name}/my_project/") + expect(subject[:url]).to include("#{project.group.parent.name}/#{project.group.name}/#{project.path}/") end end end diff --git a/spec/services/clusters/cleanup/service_account_service_spec.rb b/spec/services/clusters/cleanup/service_account_service_spec.rb index d6b5d1a5d5c..f5a3c2e8eb1 100644 --- a/spec/services/clusters/cleanup/service_account_service_spec.rb +++ b/spec/services/clusters/cleanup/service_account_service_spec.rb @@ -55,14 +55,16 @@ RSpec.describe Clusters::Cleanup::ServiceAccountService, feature_category: :depl context 'when there is a Kubeclient::HttpError' do ['Unauthorized', 'forbidden', 'Certificate verify Failed'].each do |message| - before do - allow(kubeclient_instance_double) - .to receive(:delete_service_account) - .and_raise(Kubeclient::HttpError.new(401, message, nil)) - end + context "with error:#{message}" do + before do + allow(kubeclient_instance_double) + .to receive(:delete_service_account) + .and_raise(Kubeclient::HttpError.new(401, message, nil)) + end - it 'destroys cluster' do - expect { subject }.to change { Clusters::Cluster.where(id: cluster.id).exists? }.from(true).to(false) + it 'destroys cluster' do + expect { subject }.to change { Clusters::Cluster.where(id: cluster.id).exists? }.from(true).to(false) + end end end end diff --git a/spec/support/shared_examples/features/packages_shared_examples.rb b/spec/support/shared_examples/features/packages_shared_examples.rb index b2d087819a1..793fa25ca77 100644 --- a/spec/support/shared_examples/features/packages_shared_examples.rb +++ b/spec/support/shared_examples/features/packages_shared_examples.rb @@ -9,7 +9,7 @@ RSpec.shared_examples 'packages list' do |check_project_name: false| expect(package_row).to have_content(pkg.name) expect(package_row).to have_content(pkg.version) - expect(package_row).to have_content(pkg.project.name) if check_project_name + expect(package_row).to have_content(pkg.project.path) if check_project_name end end diff --git a/spec/workers/integrations/irker_worker_spec.rb b/spec/workers/integrations/irker_worker_spec.rb index 7a51e9cfe47..9866415c99e 100644 --- a/spec/workers/integrations/irker_worker_spec.rb +++ b/spec/workers/integrations/irker_worker_spec.rb @@ -105,7 +105,7 @@ RSpec.describe Integrations::IrkerWorker, '#perform', feature_category: :integra end def wrap_message(text) - message = "[#{project.path}] #{push_data['user_name']} #{text}" + message = "[#{project.name}] #{push_data['user_name']} #{text}" to_send = { to: channels, privmsg: message } Gitlab::Json.dump(to_send) |