diff options
Diffstat (limited to 'spec')
117 files changed, 781 insertions, 423 deletions
diff --git a/spec/features/projects/work_items/linked_work_items_spec.rb b/spec/features/projects/work_items/linked_work_items_spec.rb index 66016cf8b7b..49f723c3055 100644 --- a/spec/features/projects/work_items/linked_work_items_spec.rb +++ b/spec/features/projects/work_items/linked_work_items_spec.rb @@ -102,8 +102,8 @@ RSpec.describe 'Work item linked items', :js, feature_category: :team_planning d expect(find('.work-items-list')).to have_content('Task 1') - find_by_testid('links-menu').click - click_button 'Remove' + find_by_testid('links-child').hover + find_by_testid('remove-work-item-link').click wait_for_all_requests diff --git a/spec/features/projects/work_items/work_item_children_spec.rb b/spec/features/projects/work_items/work_item_children_spec.rb index 843afb54dec..752ea282fbf 100644 --- a/spec/features/projects/work_items/work_item_children_spec.rb +++ b/spec/features/projects/work_items/work_item_children_spec.rb @@ -87,8 +87,8 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do expect(find('[data-testid="links-child"]')).to have_content('Task 1') expect(find('[data-testid="children-count"]')).to have_content('1') - find('[data-testid="links-menu"]').click - click_button 'Remove' + find_by_testid('links-child').hover + find_by_testid('remove-work-item-link').click wait_for_all_requests diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb index a795df4dec6..b8ba1176ea2 100644 --- a/spec/finders/projects_finder_spec.rb +++ b/spec/finders/projects_finder_spec.rb @@ -66,6 +66,18 @@ RSpec.describe ProjectsFinder, feature_category: :groups_and_projects do it { is_expected.to eq([internal_project]) } end + describe 'with full_paths' do + let_it_be(:second_public_project) do + create(:project, :public, :merge_requests_enabled, :issues_disabled, group: group, name: 'second-public', path: 'second-public') + end + + context 'only returns projects matching the provided full paths' do + let(:params) { { full_paths: [public_project.full_path, second_public_project.full_path] } } + + it { is_expected.to match_array([public_project, second_public_project]) } + end + end + describe 'with id_after' do context 'only returns projects with a project id greater than given' do let(:params) { { id_after: internal_project.id } } diff --git a/spec/frontend/crm/organization_form_wrapper_spec.js b/spec/frontend/crm/organization_form_wrapper_spec.js index f15fcac71d5..4e84180b22b 100644 --- a/spec/frontend/crm/organization_form_wrapper_spec.js +++ b/spec/frontend/crm/organization_form_wrapper_spec.js @@ -2,8 +2,8 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import OrganizationFormWrapper from '~/crm/organizations/components/organization_form_wrapper.vue'; import CrmForm from '~/crm/components/crm_form.vue'; import getGroupOrganizationsQuery from '~/crm/organizations/components/graphql/get_group_organizations.query.graphql'; -import createOrganizationMutation from '~/crm/organizations/components/graphql/create_customer_relations_organization.mutation.graphql'; -import updateOrganizationMutation from '~/crm/organizations/components/graphql/update_organization.mutation.graphql'; +import createCustomerRelationsOrganizationMutation from '~/crm/organizations/components/graphql/create_customer_relations_organization.mutation.graphql'; +import updateCustomerRelationsOrganizationMutation from '~/crm/organizations/components/graphql/update_customer_relations_organization.mutation.graphql'; describe('Customer relations organization form wrapper', () => { let wrapper; @@ -48,7 +48,7 @@ describe('Customer relations organization form wrapper', () => { expect(organizationForm.props('fields')).toHaveLength(4); expect(organizationForm.props('title')).toBe('Edit organization'); expect(organizationForm.props('successMessage')).toBe('Organization has been updated.'); - expect(organizationForm.props('mutation')).toBe(updateOrganizationMutation); + expect(organizationForm.props('mutation')).toBe(updateCustomerRelationsOrganizationMutation); expect(organizationForm.props('getQuery')).toMatchObject({ query: getGroupOrganizationsQuery, variables: { groupFullPath: 'flightjs' }, @@ -69,7 +69,7 @@ describe('Customer relations organization form wrapper', () => { expect(organizationForm.props('fields')).toHaveLength(3); expect(organizationForm.props('title')).toBe('New organization'); expect(organizationForm.props('successMessage')).toBe('Organization has been added.'); - expect(organizationForm.props('mutation')).toBe(createOrganizationMutation); + expect(organizationForm.props('mutation')).toBe(createCustomerRelationsOrganizationMutation); expect(organizationForm.props('getQuery')).toMatchObject({ query: getGroupOrganizationsQuery, variables: { groupFullPath: 'flightjs' }, diff --git a/spec/frontend/organizations/settings/general/components/app_spec.js b/spec/frontend/organizations/settings/general/components/app_spec.js new file mode 100644 index 00000000000..6d75f8a9949 --- /dev/null +++ b/spec/frontend/organizations/settings/general/components/app_spec.js @@ -0,0 +1,19 @@ +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import OrganizationSettings from '~/organizations/settings/general/components/organization_settings.vue'; +import App from '~/organizations/settings/general/components/app.vue'; + +describe('OrganizationSettings', () => { + let wrapper; + + const createComponent = () => { + wrapper = shallowMountExtended(App); + }; + + beforeEach(() => { + createComponent(); + }); + + it('renders `Organization settings` section', () => { + expect(wrapper.findComponent(OrganizationSettings).exists()).toBe(true); + }); +}); diff --git a/spec/frontend/organizations/settings/general/components/organization_settings_spec.js b/spec/frontend/organizations/settings/general/components/organization_settings_spec.js new file mode 100644 index 00000000000..7645b41e3bd --- /dev/null +++ b/spec/frontend/organizations/settings/general/components/organization_settings_spec.js @@ -0,0 +1,126 @@ +import VueApollo from 'vue-apollo'; +import Vue, { nextTick } from 'vue'; + +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import OrganizationSettings from '~/organizations/settings/general/components/organization_settings.vue'; +import SettingsBlock from '~/vue_shared/components/settings/settings_block.vue'; +import NewEditForm from '~/organizations/shared/components/new_edit_form.vue'; +import { FORM_FIELD_NAME, FORM_FIELD_ID } from '~/organizations/shared/constants'; +import resolvers from '~/organizations/shared/graphql/resolvers'; +import { createAlert, VARIANT_INFO } from '~/alert'; +import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; + +Vue.use(VueApollo); +jest.useFakeTimers(); +jest.mock('~/alert'); + +describe('OrganizationSettings', () => { + let wrapper; + let mockApollo; + + const defaultProvide = { + organization: { + id: 1, + name: 'GitLab', + }, + }; + + const createComponent = ({ mockResolvers = resolvers } = {}) => { + mockApollo = createMockApollo([], mockResolvers); + + wrapper = shallowMountExtended(OrganizationSettings, { + provide: defaultProvide, + apolloProvider: mockApollo, + }); + }; + + const findForm = () => wrapper.findComponent(NewEditForm); + const submitForm = async () => { + findForm().vm.$emit('submit', { name: 'Foo bar', path: 'foo-bar' }); + await nextTick(); + }; + + beforeEach(() => { + createComponent(); + }); + + afterEach(() => { + mockApollo = null; + }); + + it('renders settings block', () => { + expect(wrapper.findComponent(SettingsBlock).exists()).toBe(true); + }); + + it('renders form with correct props', () => { + createComponent(); + + expect(findForm().props()).toMatchObject({ + loading: false, + initialFormValues: defaultProvide.organization, + fieldsToRender: [FORM_FIELD_NAME, FORM_FIELD_ID], + }); + }); + + describe('when form is submitted', () => { + describe('when API is loading', () => { + beforeEach(async () => { + const mockResolvers = { + Mutation: { + updateOrganization: jest.fn().mockReturnValueOnce(new Promise(() => {})), + }, + }; + + createComponent({ mockResolvers }); + + await submitForm(); + }); + + it('sets form `loading` prop to `true`', () => { + expect(findForm().props('loading')).toBe(true); + }); + }); + + describe('when API request is successful', () => { + beforeEach(async () => { + createComponent(); + await submitForm(); + jest.runAllTimers(); + await waitForPromises(); + }); + + it('displays info alert', () => { + expect(createAlert).toHaveBeenCalledWith({ + message: 'Organization was successfully updated.', + variant: VARIANT_INFO, + }); + }); + }); + + describe('when API request is not successful', () => { + const error = new Error(); + + beforeEach(async () => { + const mockResolvers = { + Mutation: { + updateOrganization: jest.fn().mockRejectedValueOnce(error), + }, + }; + + createComponent({ mockResolvers }); + await submitForm(); + jest.runAllTimers(); + await waitForPromises(); + }); + + it('displays error alert', () => { + expect(createAlert).toHaveBeenCalledWith({ + message: 'An error occurred updating your organization. Please try again.', + error, + captureError: true, + }); + }); + }); + }); +}); diff --git a/spec/frontend/organizations/shared/components/new_edit_form_spec.js b/spec/frontend/organizations/shared/components/new_edit_form_spec.js index 43c099fbb1c..42a6f20962d 100644 --- a/spec/frontend/organizations/shared/components/new_edit_form_spec.js +++ b/spec/frontend/organizations/shared/components/new_edit_form_spec.js @@ -1,6 +1,7 @@ import { GlButton, GlInputGroupText, GlTruncate } from '@gitlab/ui'; import NewEditForm from '~/organizations/shared/components/new_edit_form.vue'; +import { FORM_FIELD_NAME, FORM_FIELD_ID, FORM_FIELD_PATH } from '~/organizations/shared/constants'; import { mountExtended } from 'helpers/vue_test_utils_helper'; describe('NewEditForm', () => { @@ -27,6 +28,7 @@ describe('NewEditForm', () => { }; const findNameField = () => wrapper.findByLabelText('Organization name'); + const findIdField = () => wrapper.findByLabelText('Organization ID'); const findUrlField = () => wrapper.findByLabelText('Organization URL'); const submitForm = async () => { await wrapper.findByRole('button', { name: 'Create organization' }).trigger('click'); @@ -47,6 +49,45 @@ describe('NewEditForm', () => { expect(findUrlField().exists()).toBe(true); }); + describe('when `fieldsToRender` prop is set', () => { + beforeEach(() => { + createComponent({ propsData: { fieldsToRender: [FORM_FIELD_ID] } }); + }); + + it('only renders provided fields', () => { + expect(findNameField().exists()).toBe(false); + expect(findIdField().exists()).toBe(true); + expect(findUrlField().exists()).toBe(false); + }); + }); + + describe('when `initialFormValues` prop is set', () => { + beforeEach(() => { + createComponent({ + propsData: { + fieldsToRender: [FORM_FIELD_NAME, FORM_FIELD_ID, FORM_FIELD_PATH], + initialFormValues: { + [FORM_FIELD_NAME]: 'Foo bar', + [FORM_FIELD_ID]: 1, + [FORM_FIELD_PATH]: 'foo-bar', + }, + }, + }); + }); + + it('sets initial values for fields', () => { + expect(findNameField().element.value).toBe('Foo bar'); + expect(findIdField().element.value).toBe('1'); + expect(findUrlField().element.value).toBe('foo-bar'); + }); + }); + + it('renders `Organization ID` field as disabled', () => { + createComponent({ propsData: { fieldsToRender: [FORM_FIELD_ID] } }); + + expect(findIdField().attributes('disabled')).toBe('disabled'); + }); + describe('when form is submitted without filling in required fields', () => { beforeEach(async () => { createComponent(); @@ -100,6 +141,30 @@ describe('NewEditForm', () => { }); }); + describe('when `Organization URL` field is not rendered', () => { + beforeEach(async () => { + createComponent({ + propsData: { + fieldsToRender: [FORM_FIELD_NAME, FORM_FIELD_ID], + initialFormValues: { + [FORM_FIELD_NAME]: 'Foo bar', + [FORM_FIELD_ID]: 1, + [FORM_FIELD_PATH]: 'foo-bar', + }, + }, + }); + + await findNameField().setValue('Foo bar baz'); + await submitForm(); + }); + + it('does not modify `Organization URL` when typing in `Organization name`', () => { + expect(wrapper.emitted('submit')).toEqual([ + [{ name: 'Foo bar baz', id: 1, path: 'foo-bar' }], + ]); + }); + }); + describe('when `loading` prop is `true`', () => { beforeEach(() => { createComponent({ propsData: { loading: true } }); @@ -109,4 +174,46 @@ describe('NewEditForm', () => { expect(wrapper.findComponent(GlButton).props('loading')).toBe(true); }); }); + + describe('when `showCancelButton` prop is `false`', () => { + beforeEach(() => { + createComponent({ propsData: { showCancelButton: false } }); + }); + + it('does not show cancel button', () => { + expect(wrapper.findByRole('link', { name: 'Cancel' }).exists()).toBe(false); + }); + }); + + describe('when `showCancelButton` prop is `true`', () => { + beforeEach(() => { + createComponent(); + }); + + it('shows cancel button', () => { + expect(wrapper.findByRole('link', { name: 'Cancel' }).attributes('href')).toBe( + defaultProvide.organizationsPath, + ); + }); + }); + + describe('when `submitButtonText` prop is not set', () => { + beforeEach(() => { + createComponent(); + }); + + it('defaults to `Create organization`', () => { + expect(wrapper.findByRole('button', { name: 'Create organization' }).exists()).toBe(true); + }); + }); + + describe('when `submitButtonText` prop is set', () => { + beforeEach(() => { + createComponent({ propsData: { submitButtonText: 'Save changes' } }); + }); + + it('uses it for submit button', () => { + expect(wrapper.findByRole('button', { name: 'Save changes' }).exists()).toBe(true); + }); + }); }); diff --git a/spec/frontend/work_items/components/shared/work_item_link_child_contents_spec.js b/spec/frontend/work_items/components/shared/work_item_link_child_contents_spec.js index 2e1a7983dec..15c6930cc80 100644 --- a/spec/frontend/work_items/components/shared/work_item_link_child_contents_spec.js +++ b/spec/frontend/work_items/components/shared/work_item_link_child_contents_spec.js @@ -1,4 +1,4 @@ -import { GlLabel, GlIcon, GlLink } from '@gitlab/ui'; +import { GlLabel, GlIcon, GlLink, GlButton } from '@gitlab/ui'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; @@ -9,7 +9,6 @@ import { createAlert } from '~/alert'; import RichTimestampTooltip from '~/vue_shared/components/rich_timestamp_tooltip.vue'; import WorkItemLinkChildContents from '~/work_items/components/shared/work_item_link_child_contents.vue'; -import WorkItemLinksMenu from '~/work_items/components/shared/work_item_links_menu.vue'; import { WORK_ITEM_TYPE_VALUE_OBJECTIVE } from '~/work_items/constants'; import { @@ -39,7 +38,7 @@ describe('WorkItemLinkChildContents', () => { const findAllLabels = () => wrapper.findAllComponents(GlLabel); const findRegularLabel = () => findAllLabels().at(0); const findScopedLabel = () => findAllLabels().at(1); - const findLinksMenuComponent = () => wrapper.findComponent(WorkItemLinksMenu); + const findRemoveButton = () => wrapper.findComponent(GlButton); const createComponent = ({ canUpdate = true, childItem = workItemTask } = {}) => { wrapper = shallowMountExtended(WorkItemLinkChildContents, { @@ -149,18 +148,18 @@ describe('WorkItemLinkChildContents', () => { createComponent(); }); - it('renders work-item-links-menu', () => { - expect(findLinksMenuComponent().exists()).toBe(true); + it('renders remove button', () => { + expect(findRemoveButton().exists()).toBe(true); }); it('does not render work-item-links-menu when canUpdate is false', () => { createComponent({ canUpdate: false }); - expect(findLinksMenuComponent().exists()).toBe(false); + expect(findRemoveButton().exists()).toBe(false); }); it('removeChild event on menu triggers `click-remove-child` event', () => { - findLinksMenuComponent().vm.$emit('removeChild'); + findRemoveButton().vm.$emit('click'); expect(wrapper.emitted('removeChild')).toEqual([[workItemTask]]); }); diff --git a/spec/frontend/work_items/components/shared/work_item_links_menu_spec.js b/spec/frontend/work_items/components/shared/work_item_links_menu_spec.js deleted file mode 100644 index 338a70feae4..00000000000 --- a/spec/frontend/work_items/components/shared/work_item_links_menu_spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import { GlDisclosureDropdown, GlDisclosureDropdownItem } from '@gitlab/ui'; - -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import WorkItemLinksMenu from '~/work_items/components/shared/work_item_links_menu.vue'; - -describe('WorkItemLinksMenu', () => { - let wrapper; - - const createComponent = () => { - wrapper = shallowMountExtended(WorkItemLinksMenu); - }; - - const findDropdown = () => wrapper.findComponent(GlDisclosureDropdown); - const findRemoveDropdownItem = () => wrapper.findComponent(GlDisclosureDropdownItem); - - beforeEach(() => { - createComponent(); - }); - - it('renders dropdown and dropdown items', () => { - expect(findDropdown().exists()).toBe(true); - expect(findRemoveDropdownItem().exists()).toBe(true); - }); - - it('emits removeChild event on click Remove', () => { - findRemoveDropdownItem().vm.$emit('action'); - - expect(wrapper.emitted('removeChild')).toHaveLength(1); - }); -}); diff --git a/spec/frontend/work_items/components/work_item_description_spec.js b/spec/frontend/work_items/components/work_item_description_spec.js index de2895591dd..1d25bb74986 100644 --- a/spec/frontend/work_items/components/work_item_description_spec.js +++ b/spec/frontend/work_items/components/work_item_description_spec.js @@ -92,7 +92,7 @@ describe('WorkItemDescription', () => { it('passes correct autocompletion data and preview markdown sources and enables quick actions', async () => { const { iid, - project: { fullPath }, + namespace: { fullPath }, } = workItemQueryResponse.data.workItem; await createComponent({ isEditing: true }); diff --git a/spec/frontend/work_items/components/work_item_todos_spec.js b/spec/frontend/work_items/components/work_item_todos_spec.js index c76cdbcee53..d67d84e75b5 100644 --- a/spec/frontend/work_items/components/work_item_todos_spec.js +++ b/spec/frontend/work_items/components/work_item_todos_spec.js @@ -34,7 +34,7 @@ describe('WorkItemTodo component', () => { const workItemQueryResponse = workItemResponseFactory({ canUpdate: true }); const mockWorkItemId = workItemQueryResponse.data.workItem.id; const mockWorkItemIid = workItemQueryResponse.data.workItem.iid; - const mockWorkItemFullpath = workItemQueryResponse.data.workItem.project.fullPath; + const mockWorkItemFullpath = workItemQueryResponse.data.workItem.namespace.fullPath; const createTodoSuccessHandler = jest .fn() diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js index 9eb604c81cb..06d59a34367 100644 --- a/spec/frontend/work_items/mock_data.js +++ b/spec/frontend/work_items/mock_data.js @@ -112,6 +112,7 @@ export const workItemQueryResponse = { __typename: 'WorkItem', id: 'gid://gitlab/WorkItem/1', iid: '1', + archived: false, title: 'Test', state: 'OPEN', description: 'description', @@ -127,11 +128,10 @@ export const workItemQueryResponse = { webUrl: 'http://127.0.0.1:3000/root', __typename: 'UserCore', }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, workItemType: { @@ -224,6 +224,7 @@ export const updateWorkItemMutationResponse = { __typename: 'WorkItem', id: 'gid://gitlab/WorkItem/1', iid: '1', + archived: false, title: 'Updated title', state: 'OPEN', description: 'description', @@ -234,11 +235,10 @@ export const updateWorkItemMutationResponse = { author: { ...mockAssignees[0], }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, workItemType: { @@ -335,6 +335,7 @@ export const convertWorkItemMutationResponse = { __typename: 'WorkItem', id: 'gid://gitlab/WorkItem/1', iid: '1', + archived: false, title: 'Updated title', state: 'OPEN', description: 'description', @@ -345,11 +346,10 @@ export const convertWorkItemMutationResponse = { author: { ...mockAssignees[0], }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, workItemType: { @@ -626,6 +626,7 @@ export const workItemResponseFactory = ({ __typename: 'WorkItem', id: 'gid://gitlab/WorkItem/1', iid, + archived: false, title: 'Updated title', state, description: 'description', @@ -634,11 +635,10 @@ export const workItemResponseFactory = ({ updatedAt, closedAt: null, author, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, workItemType, @@ -901,6 +901,7 @@ export const createWorkItemMutationResponse = { __typename: 'WorkItem', id: 'gid://gitlab/WorkItem/1', iid: '1', + archived: false, title: 'Updated title', state: 'OPEN', description: 'description', @@ -911,11 +912,10 @@ export const createWorkItemMutationResponse = { author: { ...mockAssignees[0], }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, workItemType: { @@ -987,6 +987,7 @@ export const workItemHierarchyEmptyResponse = { { id: 'gid://gitlab/WorkItem/1', iid: '1', + archived: false, state: 'OPEN', workItemType: { id: 'gid://gitlab/WorkItems::Type/1', @@ -1000,11 +1001,10 @@ export const workItemHierarchyEmptyResponse = { updatedAt: null, closedAt: null, author: mockAssignees[0], - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, userPermissions: { @@ -1045,6 +1045,7 @@ export const workItemHierarchyNoUpdatePermissionResponse = { workItem: { id: 'gid://gitlab/WorkItem/1', iid: '1', + archived: false, state: 'OPEN', workItemType: { id: 'gid://gitlab/WorkItems::Type/6', @@ -1067,11 +1068,10 @@ export const workItemHierarchyNoUpdatePermissionResponse = { adminWorkItemLink: true, __typename: 'WorkItemPermissions', }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, confidential: false, @@ -1207,6 +1207,7 @@ export const workItemHierarchyResponse = { { id: 'gid://gitlab/WorkItem/1', iid: '1', + archived: false, workItemType: { id: 'gid://gitlab/WorkItems::Type/1', name: 'Issue', @@ -1227,11 +1228,10 @@ export const workItemHierarchyResponse = { ...mockAssignees[0], }, confidential: false, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, description: 'Issue description', @@ -1303,17 +1303,17 @@ export const workItemObjectiveMetadataWidgets = { export const workItemObjectiveWithChild = { id: 'gid://gitlab/WorkItem/12', iid: '12', + archived: false, workItemType: { id: 'gid://gitlab/WorkItems::Type/2411', name: 'Objective', iconName: 'issue-type-objective', __typename: 'WorkItemType', }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, userPermissions: { @@ -1381,6 +1381,7 @@ export const workItemHierarchyTreeResponse = { workItem: { id: 'gid://gitlab/WorkItem/2', iid: '2', + archived: false, workItemType: { id: 'gid://gitlab/WorkItems::Type/2411', name: 'Objective', @@ -1398,11 +1399,10 @@ export const workItemHierarchyTreeResponse = { __typename: 'WorkItemPermissions', }, confidential: false, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, widgets: [ @@ -1483,6 +1483,7 @@ export const changeIndirectWorkItemParentMutationResponse = { description: null, id: 'gid://gitlab/WorkItem/13', iid: '13', + archived: false, state: 'OPEN', title: 'Objective 2', confidential: false, @@ -1492,11 +1493,10 @@ export const changeIndirectWorkItemParentMutationResponse = { author: { ...mockAssignees[0], }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, reference: 'test-project-path#13', @@ -1552,6 +1552,7 @@ export const changeWorkItemParentMutationResponse = { description: null, id: 'gid://gitlab/WorkItem/2', iid: '2', + archived: false, state: 'OPEN', title: 'Foo', confidential: false, @@ -1561,11 +1562,10 @@ export const changeWorkItemParentMutationResponse = { author: { ...mockAssignees[0], }, - project: { + namespace: { __typename: 'Project', id: '1', fullPath: 'test-project-path', - archived: false, name: 'Project name', }, reference: 'test-project-path#2', diff --git a/spec/graphql/resolvers/projects_resolver_spec.rb b/spec/graphql/resolvers/projects_resolver_spec.rb index 058d46a5e86..d9c1527af86 100644 --- a/spec/graphql/resolvers/projects_resolver_spec.rb +++ b/spec/graphql/resolvers/projects_resolver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Resolvers::ProjectsResolver do +RSpec.describe Resolvers::ProjectsResolver, feature_category: :source_code_management do include GraphqlHelpers describe '#resolve' do diff --git a/spec/helpers/organizations/organization_helper_spec.rb b/spec/helpers/organizations/organization_helper_spec.rb index cf8ae358e49..5e54fea065f 100644 --- a/spec/helpers/organizations/organization_helper_spec.rb +++ b/spec/helpers/organizations/organization_helper_spec.rb @@ -91,4 +91,20 @@ RSpec.describe Organizations::OrganizationHelper, feature_category: :cell do ) end end + + describe '#organization_settings_general_app_data' do + it 'returns expected json' do + expect(Gitlab::Json.parse(helper.organization_settings_general_app_data(organization))).to eq( + { + 'organization' => { + 'id' => organization.id, + 'name' => organization.name, + 'path' => organization.path + }, + 'organizations_path' => organizations_path, + 'root_url' => root_url + } + ) + end + end end diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 20b5452d2d4..a3d77d76591 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe UsersHelper do +RSpec.describe UsersHelper, feature_category: :user_management do include TermsHelper let_it_be(:user) { create(:user, timezone: ActiveSupport::TimeZone::MAPPING['UTC']) } diff --git a/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb b/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb index c599021ac5b..f13fd0be4cd 100644 --- a/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb @@ -103,7 +103,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler, feature_category: :se shared_examples 'does not add CC address' do it 'creates a new issue and adds issue_email_participant from From header' do expect { receiver.execute }.to change { Issue.count }.by(1) - expect(Issue.last.issue_email_participants.map(&:email)).to match_array(%w(from@example.com)) + expect(Issue.last.issue_email_participants.map(&:email)).to match_array(%w[from@example.com]) end end @@ -215,7 +215,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler, feature_category: :se # 1 from issue creation # 1 from new note reply expect(Issue.last.issue_email_participants.map(&:email)) - .to match_array(%w(alan@adventuretime.ooo jake@adventuretime.ooo)) + .to match_array(%w[alan@adventuretime.ooo jake@adventuretime.ooo]) end context 'when issue_email_participants FF is disabled' do @@ -228,7 +228,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler, feature_category: :se subject expect(Issue.last.issue_email_participants.map(&:email)) - .to match_array(%w(jake@adventuretime.ooo)) + .to match_array(%w[jake@adventuretime.ooo]) end end end @@ -256,7 +256,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler, feature_category: :se subject expect(Issue.last.issue_email_participants.map(&:email)) - .to match_array(%w(alan@adventuretime.ooo)) + .to match_array(%w[alan@adventuretime.ooo]) end end end diff --git a/spec/lib/gitlab/email/handler_spec.rb b/spec/lib/gitlab/email/handler_spec.rb index d3a4d77c58e..47907401a63 100644 --- a/spec/lib/gitlab/email/handler_spec.rb +++ b/spec/lib/gitlab/email/handler_spec.rb @@ -60,10 +60,10 @@ RSpec.describe Gitlab::Email::Handler do describe 'regexps are set properly' do let(:addresses) do - %W(sent_notification_key#{Gitlab::Email::Common::UNSUBSCRIBE_SUFFIX} sent_notification_key#{Gitlab::Email::Common::UNSUBSCRIBE_SUFFIX_LEGACY}) + - %w(sent_notification_key path-to-project-123-user_email_token-merge-request) + - %w(path-to-project-123-user_email_token-issue path-to-project-123-user_email_token-issue-123) + - %w(path/to/project+user_email_token path/to/project+merge-request+user_email_token some/project) + %W[sent_notification_key#{Gitlab::Email::Common::UNSUBSCRIBE_SUFFIX} sent_notification_key#{Gitlab::Email::Common::UNSUBSCRIBE_SUFFIX_LEGACY}] + + %w[sent_notification_key path-to-project-123-user_email_token-merge-request] + + %w[path-to-project-123-user_email_token-issue path-to-project-123-user_email_token-issue-123] + + %w[path/to/project+user_email_token path/to/project+merge-request+user_email_token some/project] end before do diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb index f8084d24850..c86a83092a4 100644 --- a/spec/lib/gitlab/email/receiver_spec.rb +++ b/spec/lib/gitlab/email/receiver_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Gitlab::Email::Receiver do metadata = receiver.mail_metadata - expect(metadata.keys).to match_array(%i(mail_uid from_address to_address mail_key references delivered_to envelope_to x_envelope_to meta received_recipients cc_address)) + expect(metadata.keys).to match_array(%i[mail_uid from_address to_address mail_key references delivered_to envelope_to x_envelope_to meta received_recipients cc_address]) expect(metadata[:meta]).to include(client_id: client_id, project: project.full_path) expect(metadata[meta_key]).to eq(meta_value) end diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb index 1b7c11dfef6..db7961fc0c9 100644 --- a/spec/lib/gitlab/encoding_helper_spec.rb +++ b/spec/lib/gitlab/encoding_helper_spec.rb @@ -214,7 +214,7 @@ RSpec.describe Gitlab::EncodingHelper, feature_category: :shared do [nil, ""], ["", ""], [" ", " "], - %w(a1 a1), + %w[a1 a1], ["编码", "\xE7\xBC\x96\xE7\xA0\x81".b] ].each do |input, result| it "encodes #{input.inspect} to #{result.inspect}" do diff --git a/spec/lib/gitlab/endpoint_attributes_spec.rb b/spec/lib/gitlab/endpoint_attributes_spec.rb index a623070c3eb..34f4221b86a 100644 --- a/spec/lib/gitlab/endpoint_attributes_spec.rb +++ b/spec/lib/gitlab/endpoint_attributes_spec.rb @@ -11,19 +11,19 @@ RSpec.describe Gitlab::EndpointAttributes, feature_category: :api do let(:controller) do Class.new(base_controller) do - feature_category :foo, %w(update edit) - feature_category :bar, %w(index show) - feature_category :quux, %w(destroy) + feature_category :foo, %w[update edit] + feature_category :bar, %w[index show] + feature_category :quux, %w[destroy] - urgency :high, %w(do_a) - urgency :low, %w(do_b do_c) + urgency :high, %w[do_a] + urgency :low, %w[do_b do_c] end end let(:subclass) do Class.new(controller) do - feature_category :baz, %w(subclass_index) - urgency :high, %w(superclass_do_something) + feature_category :baz, %w[subclass_index] + urgency :high, %w[superclass_do_something] end end diff --git a/spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb b/spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb index a854adca32b..eae6186e789 100644 --- a/spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb +++ b/spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Gitlab::ErrorTracking::StackTraceHighlightDecorator do [11, '<span id="LC1" class="line" lang="ruby"><span class="k">class</span> <span class="nc">HelloWorld</span></span>'], [12, '<span id="LC1" class="line" lang="ruby"> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">message</span></span>'], [13, '<span id="LC1" class="line" lang="ruby"> <span class="vi">@name</span> <span class="o">=</span> <span class="s1">\'World\'</span></span>'], - [14, %[<span id="LC1" class="line" lang="ruby"> <span class="nb">puts</span> <span class="s2">"Hello </span><span class="si">\#{</span><span class="vi">@name</span><span class="si">}</span><span class="s2">"</span></span>]], + [14, %(<span id="LC1" class="line" lang="ruby"> <span class="nb">puts</span> <span class="s2">"Hello </span><span class="si">\#{</span><span class="vi">@name</span><span class="si">}</span><span class="s2">"</span></span>)], [15, '<span id="LC1" class="line" lang="ruby"> <span class="k">end</span></span>'], [16, '<span id="LC1" class="line" lang="ruby"><span class="k">end</span></span>'] ] diff --git a/spec/lib/gitlab/external_authorization/client_spec.rb b/spec/lib/gitlab/external_authorization/client_spec.rb index b907b0bb262..b507fe7bde8 100644 --- a/spec/lib/gitlab/external_authorization/client_spec.rb +++ b/spec/lib/gitlab/external_authorization/client_spec.rb @@ -109,7 +109,7 @@ RSpec.describe Gitlab::ExternalAuthorization::Client do describe 'for non-ldap users with identities' do before do - %w(twitter facebook).each do |provider| + %w[twitter facebook].each do |provider| create(:identity, provider: provider, extern_uid: "#{provider}_external_id", user: user) end end diff --git a/spec/lib/gitlab/favicon_spec.rb b/spec/lib/gitlab/favicon_spec.rb index 033fa5d1b42..62071293764 100644 --- a/spec/lib/gitlab/favicon_spec.rb +++ b/spec/lib/gitlab/favicon_spec.rb @@ -60,7 +60,7 @@ RSpec.describe Gitlab::Favicon, :request_store do subject { described_class.available_status_names } it 'returns the available status names' do - expect(subject).to eq %w( + expect(subject).to eq %w[ favicon_status_canceled favicon_status_created favicon_status_failed @@ -73,7 +73,7 @@ RSpec.describe Gitlab::Favicon, :request_store do favicon_status_skipped favicon_status_success favicon_status_warning - ) + ] end end end diff --git a/spec/lib/gitlab/feature_categories_spec.rb b/spec/lib/gitlab/feature_categories_spec.rb index a35166a4499..11ddd08c968 100644 --- a/spec/lib/gitlab/feature_categories_spec.rb +++ b/spec/lib/gitlab/feature_categories_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Gitlab::FeatureCategories do - let(:fake_categories) { %w(foo bar) } + let(:fake_categories) { %w[foo bar] } subject(:feature_categories) { described_class.new(fake_categories) } diff --git a/spec/lib/gitlab/file_detector_spec.rb b/spec/lib/gitlab/file_detector_spec.rb index 8c0c56ea2c3..55bb1804d86 100644 --- a/spec/lib/gitlab/file_detector_spec.rb +++ b/spec/lib/gitlab/file_detector_spec.rb @@ -5,13 +5,13 @@ require 'spec_helper' RSpec.describe Gitlab::FileDetector do describe '.types_in_paths' do it 'returns the file types for the given paths' do - expect(described_class.types_in_paths(%w(README.md CHANGELOG VERSION VERSION))) - .to eq(%i{readme changelog version}) + expect(described_class.types_in_paths(%w[README.md CHANGELOG VERSION VERSION])) + .to eq(%i[readme changelog version]) end it 'does not include unrecognized file paths' do - expect(described_class.types_in_paths(%w(README.md foo.txt))) - .to eq(%i{readme}) + expect(described_class.types_in_paths(%w[README.md foo.txt])) + .to eq(%i[readme]) end end @@ -25,7 +25,7 @@ RSpec.describe Gitlab::FileDetector do extensions = ['txt', *Gitlab::MarkupHelper::EXTENSIONS] extensions.each do |ext| - %w(index readme).each do |file| + %w[index readme].each do |file| expect(described_class.type_of("#{file}.#{ext}")).to eq(:readme) end end @@ -45,13 +45,13 @@ RSpec.describe Gitlab::FileDetector do end it 'returns the type of a changelog file' do - %w(CHANGELOG HISTORY CHANGES NEWS).each do |file| + %w[CHANGELOG HISTORY CHANGES NEWS].each do |file| expect(described_class.type_of(file)).to eq(:changelog) end end it 'returns the type of a license file' do - %w(LICENSE LICENCE COPYING UNLICENSE UNLICENCE).each do |file| + %w[LICENSE LICENCE COPYING UNLICENSE UNLICENCE].each do |file| expect(described_class.type_of(file)).to eq(:license) end end @@ -73,7 +73,7 @@ RSpec.describe Gitlab::FileDetector do end it 'returns the type of an avatar' do - %w(logo.gif logo.png logo.jpg).each do |file| + %w[logo.gif logo.png logo.jpg].each do |file| expect(described_class.type_of(file)).to eq(:avatar) end end diff --git a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb index 6de7cab9c42..75427ac0402 100644 --- a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb +++ b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb @@ -78,13 +78,13 @@ RSpec.describe Gitlab::Gfm::ReferenceRewriter do context 'label referenced by id' do let(:text) { '#1 and ~123' } - it { is_expected.to eq %{#{old_project_ref}#1 and #{old_project_ref}~123} } + it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~123) } end context 'label referenced by text' do let(:text) { '#1 and ~"test"' } - it { is_expected.to eq %{#{old_project_ref}#1 and #{old_project_ref}~123} } + it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~123) } end end @@ -99,13 +99,13 @@ RSpec.describe Gitlab::Gfm::ReferenceRewriter do context 'label referenced by id' do let(:text) { '#1 and ~321' } - it { is_expected.to eq %{#{old_project_ref}#1 and #{old_project_ref}~321} } + it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~321) } end context 'label referenced by text' do let(:text) { '#1 and ~"group label"' } - it { is_expected.to eq %{#{old_project_ref}#1 and #{old_project_ref}~321} } + it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~321) } end end end @@ -149,7 +149,7 @@ RSpec.describe Gitlab::Gfm::ReferenceRewriter do let(:text) { 'milestone: %"9.0"' } - it { is_expected.to eq %[milestone: #{old_project_ref}%"9.0"] } + it { is_expected.to eq %(milestone: #{old_project_ref}%"9.0") } end context 'when referring to group milestone' do diff --git a/spec/lib/gitlab/git/merge_base_spec.rb b/spec/lib/gitlab/git/merge_base_spec.rb index fda2232c2c3..cbe47aae852 100644 --- a/spec/lib/gitlab/git/merge_base_spec.rb +++ b/spec/lib/gitlab/git/merge_base_spec.rb @@ -11,13 +11,13 @@ RSpec.describe Gitlab::Git::MergeBase do shared_context 'existing refs with a merge base', :existing_refs do let(:refs) do - %w(304d257dcb821665ab5110318fc58a007bd104ed 0031876facac3f2b2702a0e53a26e89939a42209) + %w[304d257dcb821665ab5110318fc58a007bd104ed 0031876facac3f2b2702a0e53a26e89939a42209] end end shared_context 'when passing a missing ref', :missing_ref do let(:refs) do - %w(304d257dcb821665ab5110318fc58a007bd104ed aaaa) + %w[304d257dcb821665ab5110318fc58a007bd104ed aaaa] end end @@ -51,13 +51,13 @@ RSpec.describe Gitlab::Git::MergeBase do end it 'returns a merge base when passing 2 branch names' do - merge_base = described_class.new(repository, %w(master feature)) + merge_base = described_class.new(repository, %w[master feature]) expect(merge_base.sha).to be_present end it 'returns a merge base when passing a tag name' do - merge_base = described_class.new(repository, %w(master v1.0.0)) + merge_base = described_class.new(repository, %w[master v1.0.0]) expect(merge_base.sha).to be_present end diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 47b5986cfd8..5791d9c524f 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -2435,7 +2435,7 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen end it 'deletes all refs except those with the specified prefixes' do - repository.delete_all_refs_except(%w(refs/keep refs/also-keep refs/heads)) + repository.delete_all_refs_except(%w[refs/keep refs/also-keep refs/heads]) expect(repository.ref_exists?("refs/delete/a")).to be(false) expect(repository.ref_exists?("refs/also-delete/b")).to be(false) expect(repository.ref_exists?("refs/keep/c")).to be(true) @@ -2722,15 +2722,15 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen describe '#check_objects_exist' do it 'returns hash specifying which object exists in repo' do - refs_exist = %w( + refs_exist = %w[ b83d6e391c22777fca1ed3012fce84f633d7fed0 498214de67004b1da3d820901307bed2a68a8ef6 1b12f15a11fc6e62177bef08f47bc7b5ce50b141 - ) - refs_dont_exist = %w( + ] + refs_dont_exist = %w[ 1111111111111111111111111111111111111111 2222222222222222222222222222222222222222 - ) + ] object_existence_map = repository.check_objects_exist(refs_exist + refs_dont_exist) expect(object_existence_map).to eq({ 'b83d6e391c22777fca1ed3012fce84f633d7fed0' => true, diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index 1b205aa5c85..975e8bdd3ac 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -957,7 +957,7 @@ RSpec.describe Gitlab::GitAccess, :aggregate_failures, feature_category: :system } } - [%w(feature exact), ['feat*', 'wildcard']].each do |protected_branch_name, protected_branch_type| + [%w[feature exact], ['feat*', 'wildcard']].each do |protected_branch_name, protected_branch_type| context do let(:who_can_action) { :maintainers_can_push } let(:protected_branch) { create(:protected_branch, who_can_action, name: protected_branch_name, project: project) } diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb index bd0341d51bf..f50675fee60 100644 --- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb @@ -1184,7 +1184,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService, feature_category: :source patch_names.map { |name| File.read(File.join(patches_folder, name)) }.join("\n") end - let(:patch_names) { %w(0001-This-does-not-apply-to-the-feature-branch.patch) } + let(:patch_names) { %w[0001-This-does-not-apply-to-the-feature-branch.patch] } let(:branch_name) { 'branch-with-patches' } subject(:commit_patches) do @@ -1203,7 +1203,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService, feature_category: :source end context 'when the patch could not be applied' do - let(:patch_names) { %w(0001-This-does-not-apply-to-the-feature-branch.patch) } + let(:patch_names) { %w[0001-This-does-not-apply-to-the-feature-branch.patch] } let(:branch_name) { 'feature' } it 'raises the correct error' do diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb index ae9276cf90b..118b316f2d4 100644 --- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb @@ -67,7 +67,7 @@ RSpec.describe Gitlab::GitalyClient::RefService, feature_category: :gitaly do .with(gitaly_request_with_params(merged_only: true, merged_branches: ['test']), kind_of(Hash)) .and_return([]) - client.merged_branches(%w(test)) + client.merged_branches(%w[test]) end end @@ -425,7 +425,7 @@ RSpec.describe Gitlab::GitalyClient::RefService, feature_category: :gitaly do end describe '#delete_refs' do - let(:prefixes) { %w(refs/heads refs/keep-around) } + let(:prefixes) { %w[refs/heads refs/keep-around] } subject(:delete_refs) { client.delete_refs(except_with_prefixes: prefixes) } diff --git a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb index 91311a8e90f..b5fe8c207c8 100644 --- a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb @@ -99,7 +99,7 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter, feature_category: : end context 'when the note have invalid chars' do - let(:note_body) { %{There were an invalid char "\u0000" <= right here} } + let(:note_body) { %(There were an invalid char "\u0000" <= right here) } it 'removes invalid chars' do expect(importer.user_finder) diff --git a/spec/lib/gitlab/github_import/object_counter_spec.rb b/spec/lib/gitlab/github_import/object_counter_spec.rb index e41a2cff989..964bdd6aad1 100644 --- a/spec/lib/gitlab/github_import/object_counter_spec.rb +++ b/spec/lib/gitlab/github_import/object_counter_spec.rb @@ -68,6 +68,16 @@ RSpec.describe Gitlab::GithubImport::ObjectCounter, :clean_gitlab_redis_cache, f 'imported' => { 'issue' => 8 } ) end + + it 'uses the same TTL as when incrementing' do + expect(Gitlab::Cache::Import::Caching) + .to receive(:read_integer) + .with(anything, timeout: described_class::IMPORT_CACHING_TIMEOUT) + .twice + .and_call_original + + described_class.summary(project) + end end context 'when import is in progress but cache expired' do diff --git a/spec/lib/gitlab/graphql/known_operations_spec.rb b/spec/lib/gitlab/graphql/known_operations_spec.rb index c7bc47e1e6a..acb85bc737b 100644 --- a/spec/lib/gitlab/graphql/known_operations_spec.rb +++ b/spec/lib/gitlab/graphql/known_operations_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Gitlab::Graphql::KnownOperations do using RSpec::Parameterized::TableSyntax # Include duplicated operation names to test that we are unique-ifying them - let(:fake_operations) { %w(foo foo bar bar) } + let(:fake_operations) { %w[foo foo bar bar] } let(:fake_schema) do Class.new(GraphQL::Schema) do query Graphql::FakeQueryType @@ -34,7 +34,7 @@ RSpec.describe Gitlab::Graphql::KnownOperations do describe "#operations" do it "returns array of known operations" do - expect(subject.operations.map(&:name)).to match_array(%w(unknown foo bar)) + expect(subject.operations.map(&:name)).to match_array(%w[unknown foo bar]) end end diff --git a/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb b/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb index f0312293469..f077cff6875 100644 --- a/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb +++ b/spec/lib/gitlab/graphql/tracers/metrics_tracer_spec.rb @@ -6,7 +6,7 @@ require 'rspec-parameterized' RSpec.describe Gitlab::Graphql::Tracers::MetricsTracer do using RSpec::Parameterized::TableSyntax - let(:default_known_operations) { ::Gitlab::Graphql::KnownOperations.new(%w(lorem foo bar)) } + let(:default_known_operations) { ::Gitlab::Graphql::KnownOperations.new(%w[lorem foo bar]) } let(:fake_schema) do Class.new(GraphQL::Schema) do diff --git a/spec/lib/gitlab/hashed_path_spec.rb b/spec/lib/gitlab/hashed_path_spec.rb index 051c5196748..cf31e891957 100644 --- a/spec/lib/gitlab/hashed_path_spec.rb +++ b/spec/lib/gitlab/hashed_path_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Gitlab::HashedPath do end context 'when path contains multiple values' do - let(:path) { %w(path1 path2) } + let(:path) { %w[path1 path2] } it 'returns the disk path' do expect(subject).to match(%r[\h{2}/\h{2}/\h{64}/path1/path2]) diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index 173131b1d5c..ef3765e479f 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -43,7 +43,7 @@ RSpec.describe Gitlab::Highlight do it 'returns plain version for unknown lexer context' do result = described_class.highlight(plain_text_file_name, plain_text_content) - expect(result).to eq(%[<span id="LC1" class="line" lang="plaintext">plain text contents</span>]) + expect(result).to eq(%(<span id="LC1" class="line" lang="plaintext">plain text contents</span>)) end context 'when content is too long to be highlighted' do diff --git a/spec/lib/gitlab/i18n/translation_entry_spec.rb b/spec/lib/gitlab/i18n/translation_entry_spec.rb index df503e68cf1..3531314cf9c 100644 --- a/spec/lib/gitlab/i18n/translation_entry_spec.rb +++ b/spec/lib/gitlab/i18n/translation_entry_spec.rb @@ -108,7 +108,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do describe '#msgid_contains_newlines' do it 'is true when the msgid is an array' do - data = { msgid: %w(hello world) } + data = { msgid: %w[hello world] } entry = described_class.new(entry_data: data, nplurals: 2) expect(entry.msgid_has_multiple_lines?).to be_truthy @@ -117,7 +117,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do describe '#plural_id_contains_newlines' do it 'is true when the msgid is an array' do - data = { msgid_plural: %w(hello world) } + data = { msgid_plural: %w[hello world] } entry = described_class.new(entry_data: data, nplurals: 2) expect(entry.plural_id_has_multiple_lines?).to be_truthy @@ -126,7 +126,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do describe '#translations_contain_newlines' do it 'is true when the msgid is an array' do - data = { msgstr: %w(hello world) } + data = { msgstr: %w[hello world] } entry = described_class.new(entry_data: data, nplurals: 2) expect(entry.translations_have_multiple_lines?).to be_truthy diff --git a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb index fc794f11499..2046e1b5ae5 100644 --- a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb +++ b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb @@ -100,7 +100,7 @@ RSpec.describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrat describe '#log_validation_errors' do it 'add the message to the shared context' do - errors = %w(test_message test_message2) + errors = %w[test_message test_message2] allow(service).to receive(:invalid?).and_return(true) allow(service.errors).to receive(:full_messages).and_return(errors) diff --git a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb index 297fe3ade07..0f9cbe8aea3 100644 --- a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb +++ b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy do describe 'validations' do it 'only POST and PUT method allowed' do - %w(POST post PUT put).each do |method| + %w[POST post PUT put].each do |method| expect(subject.new(url: example_url, http_method: method)).to be_valid end diff --git a/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb index 272c2629b08..9d69e1fec05 100644 --- a/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb +++ b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb @@ -34,7 +34,7 @@ RSpec.describe Gitlab::ImportExport::AttributeCleaner do 'note_ids' => [1, 2, 3], 'remote_attachment_url' => 'http://something.dodgy', 'remote_attachment_request_header' => 'bad value', - 'remote_attachment_urls' => %w(http://something.dodgy http://something.okay), + 'remote_attachment_urls' => %w[http://something.dodgy http://something.okay], 'attributes' => { 'issue_ids' => [1, 2, 3], 'merge_request_ids' => [1, 2, 3], diff --git a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb index 08abd7908d2..996b32ed341 100644 --- a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb +++ b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Gitlab::ImportExport::AttributesPermitter, feature_category: :imp EOF end - let(:file) { Tempfile.new(%w(import_export .yml)) } + let(:file) { Tempfile.new(%w[import_export .yml]) } let(:config_hash) { Gitlab::ImportExport::Config.new(config: file.path).to_h } before do diff --git a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb index dfc7202194d..f6ad3e47c30 100644 --- a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb +++ b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb @@ -156,7 +156,7 @@ RSpec.describe Gitlab::ImportExport::FastHashSerializer, :with_license, feature_ it 'has project and group labels' do label_types = subject['issues'].first['label_links'].map { |link| link['label']['type'] } - expect(label_types).to match_array(%w(ProjectLabel GroupLabel)) + expect(label_types).to match_array(%w[ProjectLabel GroupLabel]) end it 'has priorities associated to labels' do diff --git a/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb b/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb index 486d179ae05..a7aeb9e8c3b 100644 --- a/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb +++ b/spec/lib/gitlab/import_export/json/ndjson_writer_spec.rb @@ -54,7 +54,7 @@ RSpec.describe Gitlab::ImportExport::Json::NdjsonWriter, feature_category: :impo describe "#write_relation_array" do it "writes json in correct files" do values = [{ "key" => "value_1", "key_1" => "value_1" }, { "key" => "value_2", "key_1" => "value_2" }] - relations = %w(relation1 relation2) + relations = %w[relation1 relation2] relations.each do |relation| subject.write_relation_array(exportable_path, relation, values.to_enum) end diff --git a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb index fe064c50b9e..042a49f9419 100644 --- a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Gitlab::ImportExport::LfsRestorer do # Use the LfsSaver to save data to be restored def save_lfs_data - %w(project wiki).each do |repository_type| + %w[project wiki].each do |repository_type| create( :lfs_objects_project, project: project, diff --git a/spec/lib/gitlab/import_export/lfs_saver_spec.rb b/spec/lib/gitlab/import_export/lfs_saver_spec.rb index 5b6f50025ff..bd225265ef0 100644 --- a/spec/lib/gitlab/import_export/lfs_saver_spec.rb +++ b/spec/lib/gitlab/import_export/lfs_saver_spec.rb @@ -60,7 +60,7 @@ RSpec.describe Gitlab::ImportExport::LfsSaver do describe 'saving a json file' do before do # Create two more LfsObjectProject records with different `repository_type`s - %w(wiki design).each do |repository_type| + %w[wiki design].each do |repository_type| create( :lfs_objects_project, project: project, diff --git a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb index 1bf1e5b47e1..2e82351db10 100644 --- a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb @@ -190,7 +190,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver, :with_license, feature_ it 'has project and group labels' do label_types = subject.first['label_links'].map { |link| link['label']['type'] } - expect(label_types).to match_array(%w(ProjectLabel GroupLabel)) + expect(label_types).to match_array(%w[ProjectLabel GroupLabel]) end it 'has priorities associated to labels' do diff --git a/spec/lib/gitlab/import_export/saver_spec.rb b/spec/lib/gitlab/import_export/saver_spec.rb index a34e68ecd19..ba38a5d7960 100644 --- a/spec/lib/gitlab/import_export/saver_spec.rb +++ b/spec/lib/gitlab/import_export/saver_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Gitlab::ImportExport::Saver do subject.save # rubocop:disable Rails/SaveBang expect(ImportExportUpload.find_by(project: project).export_file.url) - .to match(%r[/uploads/-/system/import_export_upload/export_file.*]) + .to match(%r{/uploads/-/system/import_export_upload/export_file.*}) end it 'logs metrics after saving' do diff --git a/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb b/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb index d7b1b180e2e..97e3caba9b3 100644 --- a/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do expect(restorer.restore).to be_truthy end.to change { SnippetRepository.count }.by(1) - snippet.repository.expire_method_caches(%i(exists?)) + snippet.repository.expire_method_caches(%i[exists?]) expect(snippet.repository_exists?).to be_truthy blob = snippet.repository.blob_at(snippet.default_branch, snippet.file_name) diff --git a/spec/lib/gitlab/import_sources_spec.rb b/spec/lib/gitlab/import_sources_spec.rb index db23e3b1fd4..19f17c9079d 100644 --- a/spec/lib/gitlab/import_sources_spec.rb +++ b/spec/lib/gitlab/import_sources_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Gitlab::ImportSources, feature_category: :importers do describe '.values' do it 'returns an array' do expected = - %w( + %w[ github bitbucket bitbucket_server @@ -33,7 +33,7 @@ RSpec.describe Gitlab::ImportSources, feature_category: :importers do gitlab_project gitea manifest - ) + ] expect(described_class.values).to eq(expected) end @@ -42,14 +42,14 @@ RSpec.describe Gitlab::ImportSources, feature_category: :importers do describe '.importer_names' do it 'returns an array of importer names' do expected = - %w( + %w[ github bitbucket bitbucket_server fogbugz gitlab_project gitea - ) + ] expect(described_class.importer_names).to eq(expected) end diff --git a/spec/lib/gitlab/instrumentation/redis_cluster_validator_spec.rb b/spec/lib/gitlab/instrumentation/redis_cluster_validator_spec.rb index ddb5245f825..ea5a32a25ff 100644 --- a/spec/lib/gitlab/instrumentation/redis_cluster_validator_spec.rb +++ b/spec/lib/gitlab/instrumentation/redis_cluster_validator_spec.rb @@ -11,25 +11,25 @@ RSpec.describe Gitlab::Instrumentation::RedisClusterValidator, feature_category: using RSpec::Parameterized::TableSyntax where(:command, :arguments, :keys, :is_valid) do - :rename | %w(foo bar) | 2 | false - :RENAME | %w(foo bar) | 2 | false - 'rename' | %w(foo bar) | 2 | false - 'RENAME' | %w(foo bar) | 2 | false - :rename | %w(iaa ahy) | 2 | true # 'iaa' and 'ahy' hash to the same slot - :rename | %w({foo}:1 {foo}:2) | 2 | true - :rename | %w(foo foo bar) | 2 | true # This is not a valid command but should not raise here - :mget | %w(foo bar) | 2 | false - :mget | %w(foo foo bar) | 3 | false - :mget | %w(foo foo) | 2 | true - :blpop | %w(foo bar 1) | 2 | false - :blpop | %w(foo foo 1) | 2 | true - :mset | %w(foo a bar a) | 2 | false - :mset | %w(foo a foo a) | 2 | true - :del | %w(foo bar) | 2 | false - :del | [%w(foo bar)] | 2 | false # Arguments can be a nested array - :del | %w(foo foo) | 2 | true - :hset | %w(foo bar) | 1 | nil # Single key write - :get | %w(foo) | 1 | nil # Single key read + :rename | %w[foo bar] | 2 | false + :RENAME | %w[foo bar] | 2 | false + 'rename' | %w[foo bar] | 2 | false + 'RENAME' | %w[foo bar] | 2 | false + :rename | %w[iaa ahy] | 2 | true # 'iaa' and 'ahy' hash to the same slot + :rename | %w[{foo}:1 {foo}:2] | 2 | true + :rename | %w[foo foo bar] | 2 | true # This is not a valid command but should not raise here + :mget | %w[foo bar] | 2 | false + :mget | %w[foo foo bar] | 3 | false + :mget | %w[foo foo] | 2 | true + :blpop | %w[foo bar 1] | 2 | false + :blpop | %w[foo foo 1] | 2 | true + :mset | %w[foo a bar a] | 2 | false + :mset | %w[foo a foo a] | 2 | true + :del | %w[foo bar] | 2 | false + :del | [%w[foo bar]] | 2 | false # Arguments can be a nested array + :del | %w[foo foo] | 2 | true + :hset | %w[foo bar] | 1 | nil # Single key write + :get | %w[foo] | 1 | nil # Single key read :mget | [] | 0 | true # This is invalid, but not because it's a cross-slot command end diff --git a/spec/lib/gitlab/issues/rebalancing/state_spec.rb b/spec/lib/gitlab/issues/rebalancing/state_spec.rb index 5adf1328b87..b457e0bf1dc 100644 --- a/spec/lib/gitlab/issues/rebalancing/state_spec.rb +++ b/spec/lib/gitlab/issues/rebalancing/state_spec.rb @@ -67,11 +67,11 @@ RSpec.describe Gitlab::Issues::Rebalancing::State, :clean_gitlab_redis_shared_st end it 'returns array of issue ids' do - expect(rebalance_caching.get_cached_issue_ids(0, 100)).to eq(%w(1 2 3)) + expect(rebalance_caching.get_cached_issue_ids(0, 100)).to eq(%w[1 2 3]) end it 'limits returned values' do - expect(rebalance_caching.get_cached_issue_ids(0, 2)).to eq(%w(1 2)) + expect(rebalance_caching.get_cached_issue_ids(0, 2)).to eq(%w[1 2]) end context 'when caching duplicate issue_ids' do @@ -84,7 +84,7 @@ RSpec.describe Gitlab::Issues::Rebalancing::State, :clean_gitlab_redis_shared_st end it 'returns cached issues with latest scores' do - expect(rebalance_caching.get_cached_issue_ids(0, 100)).to eq(%w(3 2 1)) + expect(rebalance_caching.get_cached_issue_ids(0, 100)).to eq(%w[3 2 1]) end end end diff --git a/spec/lib/gitlab/jira_import/handle_labels_service_spec.rb b/spec/lib/gitlab/jira_import/handle_labels_service_spec.rb index b8c0dc64581..82233641778 100644 --- a/spec/lib/gitlab/jira_import/handle_labels_service_spec.rb +++ b/spec/lib/gitlab/jira_import/handle_labels_service_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Gitlab::JiraImport::HandleLabelsService do let_it_be(:other_project_label) { create(:label, title: 'feature') } let_it_be(:group_label) { create(:group_label, group: group, title: 'dev') } - let(:jira_labels) { %w(bug feature dev group::new) } + let(:jira_labels) { %w[bug feature dev group::new] } subject { described_class.new(project, jira_labels).execute } @@ -23,7 +23,7 @@ RSpec.describe Gitlab::JiraImport::HandleLabelsService do it 'creates the missing labels on the project level' do expect { subject }.to change { Label.count }.from(3).to(5) - expect(created_labels.map(&:title)).to match_array(%w(feature group::new)) + expect(created_labels.map(&:title)).to match_array(%w[feature group::new]) end it 'returns the id of all labels matching the title' do @@ -32,7 +32,7 @@ RSpec.describe Gitlab::JiraImport::HandleLabelsService do end context 'when no provided jira labels are missing' do - let(:jira_labels) { %w(bug dev) } + let(:jira_labels) { %w[bug dev] } it 'does not create any new labels' do expect { subject }.not_to change { Label.count }.from(3) diff --git a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb index 30ad24472b4..98958d8a92e 100644 --- a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb +++ b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Gitlab::JiraImport::IssueSerializer do end let(:priority_field) { { 'name' => 'Medium' } } - let(:labels_field) { %w(bug dev backend frontend) } + let(:labels_field) { %w[bug dev backend frontend] } let(:fields) do { @@ -101,7 +101,7 @@ RSpec.describe Gitlab::JiraImport::IssueSerializer do end context 'when there are no new labels' do - let(:labels_field) { %w(bug dev) } + let(:labels_field) { %w[bug dev] } it 'assigns the labels to the Issue hash' do expect(subject[:label_ids]).to match_array([project_label.id, group_label.id]) diff --git a/spec/lib/gitlab/jira_import/labels_importer_spec.rb b/spec/lib/gitlab/jira_import/labels_importer_spec.rb index 4fb5e363475..7579e2c65f4 100644 --- a/spec/lib/gitlab/jira_import/labels_importer_spec.rb +++ b/spec/lib/gitlab/jira_import/labels_importer_spec.rb @@ -36,8 +36,8 @@ RSpec.describe Gitlab::JiraImport::LabelsImporter do let_it_be(:jira_import_with_label) { create(:jira_import_state, label: label, project: project) } let_it_be(:issue_label) { create(:label, project: project, title: 'bug') } - let(:jira_labels_1) { { "maxResults" => 2, "startAt" => 0, "total" => 3, "isLast" => false, "values" => %w(backend bug) } } - let(:jira_labels_2) { { "maxResults" => 2, "startAt" => 2, "total" => 3, "isLast" => true, "values" => %w(feature) } } + let(:jira_labels_1) { { "maxResults" => 2, "startAt" => 0, "total" => 3, "isLast" => false, "values" => %w[backend bug] } } + let(:jira_labels_2) { { "maxResults" => 2, "startAt" => 2, "total" => 3, "isLast" => true, "values" => %w[feature] } } context 'when labels are returned from jira' do before do @@ -55,8 +55,8 @@ RSpec.describe Gitlab::JiraImport::LabelsImporter do end it 'calls Gitlab::JiraImport::HandleLabelsService' do - expect(Gitlab::JiraImport::HandleLabelsService).to receive(:new).with(project, %w(backend bug)).and_return(double(execute: [1, 2])) - expect(Gitlab::JiraImport::HandleLabelsService).to receive(:new).with(project, %w(feature)).and_return(double(execute: [3])) + expect(Gitlab::JiraImport::HandleLabelsService).to receive(:new).with(project, %w[backend bug]).and_return(double(execute: [1, 2])) + expect(Gitlab::JiraImport::HandleLabelsService).to receive(:new).with(project, %w[feature]).and_return(double(execute: [3])) subject end @@ -92,7 +92,7 @@ RSpec.describe Gitlab::JiraImport::LabelsImporter do end context 'when the isLast argument is missing' do - let(:jira_labels) { { "maxResults" => 2, "startAt" => 0, "total" => 3, "values" => %w(bug dev) } } + let(:jira_labels) { { "maxResults" => 2, "startAt" => 0, "total" => 3, "values" => %w[bug dev] } } it_behaves_like 'no labels handling' end diff --git a/spec/lib/gitlab/kubernetes/kubectl_cmd_spec.rb b/spec/lib/gitlab/kubernetes/kubectl_cmd_spec.rb index 3028e0a13aa..f88f7c4c108 100644 --- a/spec/lib/gitlab/kubernetes/kubectl_cmd_spec.rb +++ b/spec/lib/gitlab/kubernetes/kubectl_cmd_spec.rb @@ -7,7 +7,7 @@ require_relative '../../../../lib/gitlab/kubernetes/pod_cmd' RSpec.describe Gitlab::Kubernetes::KubectlCmd do describe '.delete' do it 'constructs string properly' do - args = %w(resource_type type --flag-1 --flag-2) + args = %w[resource_type type --flag-1 --flag-2] expected_command = 'kubectl delete resource_type type --flag-1 --flag-2' @@ -31,7 +31,7 @@ RSpec.describe Gitlab::Kubernetes::KubectlCmd do context 'with optional args' do it 'constructs command properly with many args' do - args = %w(arg-1 --flag-0-1 arg-2 --flag-0-2) + args = %w[arg-1 --flag-0-1 arg-2 --flag-0-2] expected_command = 'kubectl apply -f filename arg-1 --flag-0-1 arg-2 --flag-0-2' diff --git a/spec/lib/gitlab/kubernetes/role_spec.rb b/spec/lib/gitlab/kubernetes/role_spec.rb index acb9b5d4e8e..288a5406372 100644 --- a/spec/lib/gitlab/kubernetes/role_spec.rb +++ b/spec/lib/gitlab/kubernetes/role_spec.rb @@ -9,9 +9,9 @@ RSpec.describe Gitlab::Kubernetes::Role do let(:rules) do [{ - apiGroups: %w(hello.world), - resources: %w(oil diamonds coffee), - verbs: %w(say do walk run) + apiGroups: %w[hello.world], + resources: %w[oil diamonds coffee], + verbs: %w[say do walk run] }] end diff --git a/spec/lib/gitlab/language_data_spec.rb b/spec/lib/gitlab/language_data_spec.rb index bb4b0c3855c..828fd95f78e 100644 --- a/spec/lib/gitlab/language_data_spec.rb +++ b/spec/lib/gitlab/language_data_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Gitlab::LanguageData do expect(described_class.extensions).to be_a(Set) expect(described_class.extensions.count).to be > 0 # Sanity check for known extensions - expect(described_class.extensions).to include(*%w(.rb .yml .json)) + expect(described_class.extensions).to include(*%w[.rb .yml .json]) end end end diff --git a/spec/lib/gitlab/markup_helper_spec.rb b/spec/lib/gitlab/markup_helper_spec.rb index 2bffd029568..a7508288f4e 100644 --- a/spec/lib/gitlab/markup_helper_spec.rb +++ b/spec/lib/gitlab/markup_helper_spec.rb @@ -4,8 +4,8 @@ require 'fast_spec_helper' RSpec.describe Gitlab::MarkupHelper do describe '#markup?' do - %w(textile rdoc org creole wiki - mediawiki rst adoc ad asciidoc mdown md markdown).each do |type| + %w[textile rdoc org creole wiki + mediawiki rst adoc ad asciidoc mdown md markdown].each do |type| it "returns true for #{type} files" do expect(described_class.markup?("README.#{type}")).to be_truthy end @@ -17,7 +17,7 @@ RSpec.describe Gitlab::MarkupHelper do end describe '#gitlab_markdown?' do - %w(mdown mkd mkdn md markdown).each do |type| + %w[mdown mkd mkdn md markdown].each do |type| it "returns true for #{type} files" do expect(described_class.gitlab_markdown?("README.#{type}")).to be_truthy end @@ -29,7 +29,7 @@ RSpec.describe Gitlab::MarkupHelper do end describe '#asciidoc?' do - %w(adoc ad asciidoc ADOC).each do |type| + %w[adoc ad asciidoc ADOC].each do |type| it "returns true for #{type} files" do expect(described_class.asciidoc?("README.#{type}")).to be_truthy end diff --git a/spec/lib/gitlab/metrics/rails_slis_spec.rb b/spec/lib/gitlab/metrics/rails_slis_spec.rb index ef996f61082..3050c769117 100644 --- a/spec/lib/gitlab/metrics/rails_slis_spec.rb +++ b/spec/lib/gitlab/metrics/rails_slis_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Gitlab::Metrics::RailsSlis, feature_category: :error_budgets do before do - allow(Gitlab::Graphql::KnownOperations).to receive(:default).and_return(Gitlab::Graphql::KnownOperations.new(%w(foo bar))) + allow(Gitlab::Graphql::KnownOperations).to receive(:default).and_return(Gitlab::Graphql::KnownOperations.new(%w[foo bar])) end describe '.initialize_request_slis!' do diff --git a/spec/lib/gitlab/metrics/samplers/threads_sampler_spec.rb b/spec/lib/gitlab/metrics/samplers/threads_sampler_spec.rb index 5dabafb7c0b..0a3648c8b9a 100644 --- a/spec/lib/gitlab/metrics/samplers/threads_sampler_spec.rb +++ b/spec/lib/gitlab/metrics/samplers/threads_sampler_spec.rb @@ -40,11 +40,11 @@ RSpec.describe Gitlab::Metrics::Samplers::ThreadsSampler do context 'thread names', :aggregate_failures do where(:thread_names, :expected_names) do [ - [[nil], %w(unnamed)], + [[nil], %w[unnamed]], [['puma threadpool 1', 'puma threadpool 001', 'puma threadpool 002'], ['puma threadpool']], - [%w(sidekiq_worker_thread), %w(sidekiq_worker_thread)], - [%w(some_sampler some_exporter), %w(some_sampler some_exporter)], - [%w(unknown thing), %w(unrecognized)] + [%w[sidekiq_worker_thread], %w[sidekiq_worker_thread]], + [%w[some_sampler some_exporter], %w[some_sampler some_exporter]], + [%w[unknown thing], %w[unrecognized]] ] end diff --git a/spec/lib/gitlab/middleware/go_spec.rb b/spec/lib/gitlab/middleware/go_spec.rb index a3835f9eed0..4820f42ade3 100644 --- a/spec/lib/gitlab/middleware/go_spec.rb +++ b/spec/lib/gitlab/middleware/go_spec.rb @@ -206,7 +206,7 @@ RSpec.describe Gitlab::Middleware::Go, feature_category: :source_code_management expect(response[0]).to eq(404) expect(response[1]['Content-Type']).to eq('text/html') - expected_body = %{<html><body>go get #{Gitlab.config.gitlab.url}/#{project.full_path}</body></html>} + expected_body = %(<html><body>go get #{Gitlab.config.gitlab.url}/#{project.full_path}</body></html>) expect(response[2]).to eq([expected_body]) end end @@ -278,7 +278,7 @@ RSpec.describe Gitlab::Middleware::Go, feature_category: :source_code_management project_url = "http://#{Gitlab.config.gitlab.host}/#{path}" expect(response[0]).to eq(200) expect(response[1]['Content-Type']).to eq('text/html') - expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}"><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}"></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>} + expected_body = %(<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}"><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}"></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>) expect(response[2]).to eq([expected_body]) end end diff --git a/spec/lib/gitlab/middleware/multipart_spec.rb b/spec/lib/gitlab/middleware/multipart_spec.rb index 509a4bb921b..b857ed47d42 100644 --- a/spec/lib/gitlab/middleware/multipart_spec.rb +++ b/spec/lib/gitlab/middleware/multipart_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Gitlab::Middleware::Multipart do let(:params) { upload_parameters_for(key: 'file', mode: mode, filename: filename, remote_id: remote_id).merge('file.path' => '/should/not/be/read') } it 'builds an UploadedFile' do - expect_uploaded_files(original_filename: filename, remote_id: remote_id, size: uploaded_file.size, params_path: %w(file)) + expect_uploaded_files(original_filename: filename, remote_id: remote_id, size: uploaded_file.size, params_path: %w[file]) subject end @@ -61,7 +61,7 @@ RSpec.describe Gitlab::Middleware::Multipart do let(:params) { upload_parameters_for(filepath: uploaded_filepath, key: 'file', mode: mode, filename: filename) } it 'builds an UploadedFile' do - expect_uploaded_files(filepath: uploaded_filepath, original_filename: filename, size: uploaded_file.size, params_path: %w(file)) + expect_uploaded_files(filepath: uploaded_filepath, original_filename: filename, size: uploaded_file.size, params_path: %w[file]) subject end diff --git a/spec/lib/gitlab/omniauth_initializer_spec.rb b/spec/lib/gitlab/omniauth_initializer_spec.rb index 1c665ec6e18..9b46b8eccc8 100644 --- a/spec/lib/gitlab/omniauth_initializer_spec.rb +++ b/spec/lib/gitlab/omniauth_initializer_spec.rb @@ -171,7 +171,7 @@ RSpec.describe Gitlab::OmniauthInitializer do end it 'allows "args" array for app_id and app_secret' do - legacy_config = { 'name' => 'legacy', 'args' => %w(123 abc) } + legacy_config = { 'name' => 'legacy', 'args' => %w[123 abc] } expect(devise_config).to receive(:omniauth).with(:legacy, '123', 'abc') diff --git a/spec/lib/gitlab/pagination/keyset/order_spec.rb b/spec/lib/gitlab/pagination/keyset/order_spec.rb index 05bb0bb8b3a..52d2688c06e 100644 --- a/spec/lib/gitlab/pagination/keyset/order_spec.rb +++ b/spec/lib/gitlab/pagination/keyset/order_spec.rb @@ -726,7 +726,7 @@ RSpec.describe Gitlab::Pagination::Keyset::Order do end describe '#attribute_names' do - let(:expected_attribute_names) { %w(id name) } + let(:expected_attribute_names) { %w[id name] } let(:order) do described_class.build( [ diff --git a/spec/lib/gitlab/pagination/offset_header_builder_spec.rb b/spec/lib/gitlab/pagination/offset_header_builder_spec.rb index a415bad5135..f43216702a8 100644 --- a/spec/lib/gitlab/pagination/offset_header_builder_spec.rb +++ b/spec/lib/gitlab/pagination/offset_header_builder_spec.rb @@ -15,11 +15,15 @@ RSpec.describe Gitlab::Pagination::OffsetHeaderBuilder do describe '#execute' do let(:basic_links) do - %{<http://localhost?page=1&per_page=5>; rel="prev", <http://localhost?page=3&per_page=5>; rel="next", <http://localhost?page=1&per_page=5>; rel="first"} + [ + %(<http://localhost?page=1&per_page=5>; rel="prev"), + %(<http://localhost?page=3&per_page=5>; rel="next"), + %(<http://localhost?page=1&per_page=5>; rel="first") + ].join(', ') end let(:last_link) do - %{, <http://localhost?page=3&per_page=5>; rel="last"} + %(, <http://localhost?page=3&per_page=5>; rel="last") end def expect_basic_headers diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index 53dc145dcc4..09a5309c778 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -108,16 +108,16 @@ RSpec.describe Gitlab::PathRegex do end let(:sitemap_words) do - %w(sitemap sitemap.xml sitemap.xml.gz) + %w[sitemap sitemap.xml sitemap.xml.gz] end let(:deprecated_routes) do # profile was deprecated in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51646 - %w(profile s) + %w[profile s] end let(:ee_top_level_words) do - %w(unsubscribes v2) + %w[unsubscribes v2] end let(:files_in_public) do @@ -126,7 +126,7 @@ RSpec.describe Gitlab::PathRegex do .split("\n") .map { |entry| entry.start_with?('public/-/') ? '-' : entry.gsub('public/', '') } .uniq - tracked + %w(assets uploads) + tracked + %w[assets uploads] end # All routes that start with a namespaced path, that have 1 or more diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb index 0a186b07d19..78455cb705f 100644 --- a/spec/lib/gitlab/popen_spec.rb +++ b/spec/lib/gitlab/popen_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Gitlab::Popen do context 'zero status' do before do - @output, @status = @klass.new.popen(%w(ls), path) + @output, @status = @klass.new.popen(%w[ls], path) end it { expect(@status).to be_zero } @@ -33,7 +33,7 @@ RSpec.describe Gitlab::Popen do context 'non-zero status' do before do - @output, @status = @klass.new.popen(%w(cat NOTHING), path) + @output, @status = @klass.new.popen(%w[cat NOTHING], path) end it { expect(@status).to eq(1) } @@ -64,7 +64,7 @@ RSpec.describe Gitlab::Popen do it 'calls popen3 with the provided environment variables' do expect(Open3).to receive(:popen3).with(vars, 'ls', options) - @output, @status = @klass.new.popen(%w(ls), path, { 'foobar' => 123 }) + @output, @status = @klass.new.popen(%w[ls], path, { 'foobar' => 123 }) end end @@ -83,7 +83,7 @@ RSpec.describe Gitlab::Popen do context 'without a directory argument' do before do - @output, @status = @klass.new.popen(%w(ls)) + @output, @status = @klass.new.popen(%w[ls]) end it { expect(@status).to be_zero } diff --git a/spec/lib/gitlab/process_management_spec.rb b/spec/lib/gitlab/process_management_spec.rb index fbd39702efb..709e4611954 100644 --- a/spec/lib/gitlab/process_management_spec.rb +++ b/spec/lib/gitlab/process_management_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Gitlab::ProcessManagement do expect(described_class).to receive(:trap).ordered.with(:INT) expect(described_class).to receive(:trap).ordered.with(:HUP) - described_class.trap_signals(%i(INT HUP)) + described_class.trap_signals(%i[INT HUP]) end end @@ -17,7 +17,7 @@ RSpec.describe Gitlab::ProcessManagement do expect(described_class).to receive(:trap).ordered.with(:INT, 'DEFAULT') expect(described_class).to receive(:trap).ordered.with(:HUP, 'DEFAULT') - described_class.modify_signals(%i(INT HUP), 'DEFAULT') + described_class.modify_signals(%i[INT HUP], 'DEFAULT') end end diff --git a/spec/lib/gitlab/process_supervisor_spec.rb b/spec/lib/gitlab/process_supervisor_spec.rb index 18de5053362..8c18bbb758d 100644 --- a/spec/lib/gitlab/process_supervisor_spec.rb +++ b/spec/lib/gitlab/process_supervisor_spec.rb @@ -152,13 +152,13 @@ RSpec.describe Gitlab::ProcessSupervisor, feature_category: :application_perform end context 'termination signals' do - let(:term_signals) { %i(INT TERM) } + let(:term_signals) { %i[INT TERM] } context 'when TERM results in timely shutdown of processes' do it 'forwards them to observed processes without waiting for grace period to expire' do allow(Gitlab::ProcessManagement).to receive(:any_alive?).and_return(false) - expect(Gitlab::ProcessManagement).to receive(:trap_signals).ordered.with(%i(INT TERM)).and_yield(:TERM) + expect(Gitlab::ProcessManagement).to receive(:trap_signals).ordered.with(%i[INT TERM]).and_yield(:TERM) expect(Gitlab::ProcessManagement).to receive(:signal_processes).ordered.with(process_ids, :TERM) expect(supervisor).not_to receive(:sleep).with(check_terminate_interval_seconds) @@ -168,7 +168,7 @@ RSpec.describe Gitlab::ProcessSupervisor, feature_category: :application_perform context 'when TERM does not result in timely shutdown of processes' do it 'issues a KILL signal after the grace period expires' do - expect(Gitlab::ProcessManagement).to receive(:trap_signals).with(%i(INT TERM)).and_yield(:TERM) + expect(Gitlab::ProcessManagement).to receive(:trap_signals).with(%i[INT TERM]).and_yield(:TERM) expect(Gitlab::ProcessManagement).to receive(:signal_processes).ordered.with(process_ids, :TERM) expect(supervisor).to receive(:sleep).ordered.with(check_terminate_interval_seconds).at_least(:once) expect(Gitlab::ProcessManagement).to receive(:signal_processes).ordered.with(process_ids, '-KILL') @@ -179,10 +179,10 @@ RSpec.describe Gitlab::ProcessSupervisor, feature_category: :application_perform end context 'forwarded signals' do - let(:forwarded_signals) { %i(USR1) } + let(:forwarded_signals) { %i[USR1] } it 'forwards given signals to the observed processes' do - expect(Gitlab::ProcessManagement).to receive(:trap_signals).with(%i(USR1)).and_yield(:USR1) + expect(Gitlab::ProcessManagement).to receive(:trap_signals).with(%i[USR1]).and_yield(:USR1) expect(Gitlab::ProcessManagement).to receive(:signal_processes).ordered.with(process_ids, :USR1) supervisor.supervise(process_ids) { [] } diff --git a/spec/lib/gitlab/quick_actions/extractor_spec.rb b/spec/lib/gitlab/quick_actions/extractor_spec.rb index f91e8d2a7ef..063b416c514 100644 --- a/spec/lib/gitlab/quick_actions/extractor_spec.rb +++ b/spec/lib/gitlab/quick_actions/extractor_spec.rb @@ -246,7 +246,7 @@ RSpec.describe Gitlab::QuickActions::Extractor, feature_category: :team_planning msg = %(hello\nworld\n/reopen\n/shrug this is great?\n/shrug meh) msg, commands = extractor.extract_commands(msg) - expect(commands).to eq [['reopen'], ['shrug', 'this is great?'], %w(shrug meh)] + expect(commands).to eq [['reopen'], ['shrug', 'this is great?'], %w[shrug meh]] expect(msg).to eq "hello\nworld\nthis is great? SHRUG\nmeh SHRUG" end diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index 37db13b76b9..9b8143f7bb8 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Gitlab::ReferenceExtractor do project.add_reporter(@u_foo) project.add_reporter(@u_bar) - subject.analyze(%{ + subject.analyze(%( Inline code: `@foo` Code block: @@ -43,7 +43,7 @@ RSpec.describe Gitlab::ReferenceExtractor do Quote: > @offteam - }) + )) expect(subject.users).to match_array([]) end diff --git a/spec/lib/gitlab/repository_cache_adapter_spec.rb b/spec/lib/gitlab/repository_cache_adapter_spec.rb index 71a20cc58fd..c35038b3b75 100644 --- a/spec/lib/gitlab/repository_cache_adapter_spec.rb +++ b/spec/lib/gitlab/repository_cache_adapter_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do include Gitlab::RepositoryCacheAdapter # can't use described_class here def letters - %w(b a c) + %w[b a c] end cache_method_as_redis_set(:letters) @@ -47,11 +47,11 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do expect(fake_repository).to receive(:_uncached_letters).once.and_call_original 2.times do - expect(fake_repository.letters).to eq(%w(a b c)) + expect(fake_repository.letters).to eq(%w[a b c]) end expect(redis_set_cache.exist?(:letters)).to eq(true) - expect(fake_repository.instance_variable_get(:@letters)).to eq(%w(a b c)) + expect(fake_repository.instance_variable_get(:@letters)).to eq(%w[a b c]) end context 'membership checks' do @@ -69,7 +69,7 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do context 'when the cache key exists' do before do - redis_set_cache.write(:letters, %w(b a c)) + redis_set_cache.write(:letters, %w[b a c]) end it 'calls #try_include? on the set cache' do @@ -300,7 +300,7 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do expect(redis_set_cache).to receive(:expire).with(:branch_names) expect(redis_hash_cache).to receive(:delete).with(:branch_names) - repository.expire_method_caches(%i(branch_names)) + repository.expire_method_caches(%i[branch_names]) end it 'does not expire caches for non-existent methods' do @@ -308,7 +308,7 @@ RSpec.describe Gitlab::RepositoryCacheAdapter do expect(Gitlab::AppLogger).to( receive(:error).with("Requested to expire non-existent method 'nonexistent' for Repository")) - repository.expire_method_caches(%i(nonexistent)) + repository.expire_method_caches(%i[nonexistent]) end end end diff --git a/spec/lib/gitlab/repository_hash_cache_spec.rb b/spec/lib/gitlab/repository_hash_cache_spec.rb index e3cc6ed69fb..4b4a2092c98 100644 --- a/spec/lib/gitlab/repository_hash_cache_spec.rb +++ b/spec/lib/gitlab/repository_hash_cache_spec.rb @@ -88,7 +88,7 @@ RSpec.describe Gitlab::RepositoryHashCache, :clean_gitlab_redis_repository_cache describe "#read_members" do subject { cache.read_members(:example, keys) } - let(:keys) { %w(test missing) } + let(:keys) { %w[test missing] } context "all data is cached" do before do @@ -140,7 +140,7 @@ RSpec.describe Gitlab::RepositoryHashCache, :clean_gitlab_redis_repository_cache end end - let(:keys) { %w(test) } + let(:keys) { %w[test] } it "records metrics" do # Here we expect it to receive "test" as a missing key because we @@ -151,7 +151,7 @@ RSpec.describe Gitlab::RepositoryHashCache, :clean_gitlab_redis_repository_cache end context "fully cached" do - let(:keys) { %w(test another) } + let(:keys) { %w[test another] } before do cache.write(:example, test_hash.merge({ "another" => "not_missing" })) @@ -169,7 +169,7 @@ RSpec.describe Gitlab::RepositoryHashCache, :clean_gitlab_redis_repository_cache end context "partially cached" do - let(:keys) { %w(test missing) } + let(:keys) { %w[test missing] } before do cache.write(:example, test_hash) @@ -187,7 +187,7 @@ RSpec.describe Gitlab::RepositoryHashCache, :clean_gitlab_redis_repository_cache end context "uncached" do - let(:keys) { %w(test missing) } + let(:keys) { %w[test missing] } it "returns a hash" do is_expected.to eq({ "test" => "was_missing", "missing" => "was_missing" }) diff --git a/spec/lib/gitlab/repository_set_cache_spec.rb b/spec/lib/gitlab/repository_set_cache_spec.rb index 23b2a2b9493..42378a16046 100644 --- a/spec/lib/gitlab/repository_set_cache_spec.rb +++ b/spec/lib/gitlab/repository_set_cache_spec.rb @@ -90,7 +90,7 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_repository_cache, end context 'single key' do - let(:keys) { %w(foo) } + let(:keys) { %w[foo] } it { is_expected.to eq(1) } @@ -102,7 +102,7 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_repository_cache, end context 'multiple keys' do - let(:keys) { %w(foo bar) } + let(:keys) { %w[foo bar] } it { is_expected.to eq(2) } diff --git a/spec/lib/gitlab/search/abuse_detection_spec.rb b/spec/lib/gitlab/search/abuse_detection_spec.rb index f9a1d0211b9..7fd72a2a48c 100644 --- a/spec/lib/gitlab/search/abuse_detection_spec.rb +++ b/spec/lib/gitlab/search/abuse_detection_spec.rb @@ -20,7 +20,7 @@ RSpec.describe Gitlab::Search::AbuseDetection, feature_category: :global_search end describe 'abusive character matching' do - refs = %w( + refs = %w[ main тест maiñ @@ -30,7 +30,7 @@ RSpec.describe Gitlab::Search::AbuseDetection, feature_category: :global_search feature/it_works really_important! 测试 - ) + ] refs.each do |ref| it "does match refs permitted by git refname: #{ref}" do diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb index b27c8d13c37..a3acb8b92ed 100644 --- a/spec/lib/gitlab/search_results_spec.rb +++ b/spec/lib/gitlab/search_results_spec.rb @@ -99,7 +99,7 @@ RSpec.describe Gitlab::SearchResults, feature_category: :global_search do describe '#aggregations' do where(:scope) do - %w(projects issues merge_requests blobs commits wiki_blobs epics milestones users unknown) + %w[projects issues merge_requests blobs commits wiki_blobs epics milestones users unknown] end with_them do diff --git a/spec/lib/gitlab/security/scan_configuration_spec.rb b/spec/lib/gitlab/security/scan_configuration_spec.rb index faa8a206d74..9151db3c5ff 100644 --- a/spec/lib/gitlab/security/scan_configuration_spec.rb +++ b/spec/lib/gitlab/security/scan_configuration_spec.rb @@ -15,7 +15,7 @@ RSpec.describe ::Gitlab::Security::ScanConfiguration do let(:configured) { true } context 'with a core scanner' do - where(type: %i(sast sast_iac secret_detection container_scanning)) + where(type: %i[sast sast_iac secret_detection container_scanning]) with_them do it { is_expected.to be_truthy } @@ -73,7 +73,7 @@ RSpec.describe ::Gitlab::Security::ScanConfiguration do let(:configured) { true } context 'with a core scanner' do - where(type: %i(sast sast_iac secret_detection)) + where(type: %i[sast sast_iac secret_detection]) with_them do it { is_expected.to be_truthy } diff --git a/spec/lib/gitlab/shard_health_cache_spec.rb b/spec/lib/gitlab/shard_health_cache_spec.rb index 0c25cc7dab5..8d0eebbb23e 100644 --- a/spec/lib/gitlab/shard_health_cache_spec.rb +++ b/spec/lib/gitlab/shard_health_cache_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Gitlab::ShardHealthCache, :clean_gitlab_redis_cache do - let(:shards) { %w(foo bar) } + let(:shards) { %w[foo bar] } before do described_class.update(shards) # rubocop:disable Rails/SaveBang @@ -23,7 +23,7 @@ RSpec.describe Gitlab::ShardHealthCache, :clean_gitlab_redis_cache do end it 'replaces the existing set' do - new_set = %w(test me more) + new_set = %w[test me more] described_class.update(new_set) # rubocop:disable Rails/SaveBang expect(described_class.cached_healthy_shards).to match_array(new_set) diff --git a/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb index 576b36c1829..1145fd02891 100644 --- a/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb +++ b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb @@ -173,7 +173,7 @@ RSpec.describe Gitlab::SidekiqConfig::CliMethods do end it 'returns the queue names of matched workers' do - expect(described_class.query_queues(query, worker_metadatas)).to match(%w(a a:2 c)) + expect(described_class.query_queues(query, worker_metadatas)).to match(%w[a a:2 c]) end end end diff --git a/spec/lib/gitlab/sidekiq_config/worker_matcher_spec.rb b/spec/lib/gitlab/sidekiq_config/worker_matcher_spec.rb index dfe9358f70b..08ead3282fd 100644 --- a/spec/lib/gitlab/sidekiq_config/worker_matcher_spec.rb +++ b/spec/lib/gitlab/sidekiq_config/worker_matcher_spec.rb @@ -51,61 +51,61 @@ RSpec.describe Gitlab::SidekiqConfig::WorkerMatcher do context 'with valid input' do where(:query, :expected_metadatas) do # worker_name - 'worker_name=WorkerA' | %w(WorkerA) - 'worker_name=WorkerA2' | %w(WorkerA2) - 'worker_name=WorkerB|worker_name=WorkerD' | %w(WorkerB) - 'worker_name!=WorkerA' | %w(WorkerA2 WorkerB WorkerC) + 'worker_name=WorkerA' | %w[WorkerA] + 'worker_name=WorkerA2' | %w[WorkerA2] + 'worker_name=WorkerB|worker_name=WorkerD' | %w[WorkerB] + 'worker_name!=WorkerA' | %w[WorkerA2 WorkerB WorkerC] # feature_category - 'feature_category=category_a' | %w(WorkerA WorkerA2) - 'feature_category=category_a,category_c' | %w(WorkerA WorkerA2 WorkerC) - 'feature_category=category_a|feature_category=category_c' | %w(WorkerA WorkerA2 WorkerC) - 'feature_category!=category_a' | %w(WorkerB WorkerC) + 'feature_category=category_a' | %w[WorkerA WorkerA2] + 'feature_category=category_a,category_c' | %w[WorkerA WorkerA2 WorkerC] + 'feature_category=category_a|feature_category=category_c' | %w[WorkerA WorkerA2 WorkerC] + 'feature_category!=category_a' | %w[WorkerB WorkerC] # has_external_dependencies - 'has_external_dependencies=true' | %w(WorkerB) - 'has_external_dependencies=false' | %w(WorkerA WorkerA2 WorkerC) - 'has_external_dependencies=true,false' | %w(WorkerA WorkerA2 WorkerB WorkerC) - 'has_external_dependencies=true|has_external_dependencies=false' | %w(WorkerA WorkerA2 WorkerB WorkerC) - 'has_external_dependencies!=true' | %w(WorkerA WorkerA2 WorkerC) + 'has_external_dependencies=true' | %w[WorkerB] + 'has_external_dependencies=false' | %w[WorkerA WorkerA2 WorkerC] + 'has_external_dependencies=true,false' | %w[WorkerA WorkerA2 WorkerB WorkerC] + 'has_external_dependencies=true|has_external_dependencies=false' | %w[WorkerA WorkerA2 WorkerB WorkerC] + 'has_external_dependencies!=true' | %w[WorkerA WorkerA2 WorkerC] # urgency - 'urgency=high' | %w(WorkerA2 WorkerB) - 'urgency=low' | %w(WorkerA) - 'urgency=high,low,throttled' | %w(WorkerA WorkerA2 WorkerB WorkerC) - 'urgency=low|urgency=throttled' | %w(WorkerA WorkerC) - 'urgency!=high' | %w(WorkerA WorkerC) + 'urgency=high' | %w[WorkerA2 WorkerB] + 'urgency=low' | %w[WorkerA] + 'urgency=high,low,throttled' | %w[WorkerA WorkerA2 WorkerB WorkerC] + 'urgency=low|urgency=throttled' | %w[WorkerA WorkerC] + 'urgency!=high' | %w[WorkerA WorkerC] # name - 'name=a' | %w(WorkerA) - 'name=a,b' | %w(WorkerA WorkerB) - 'name=a,a:2|name=b' | %w(WorkerA WorkerA2 WorkerB) - 'name!=a,a:2' | %w(WorkerB WorkerC) + 'name=a' | %w[WorkerA] + 'name=a,b' | %w[WorkerA WorkerB] + 'name=a,a:2|name=b' | %w[WorkerA WorkerA2 WorkerB] + 'name!=a,a:2' | %w[WorkerB WorkerC] # resource_boundary - 'resource_boundary=memory' | %w(WorkerB WorkerC) - 'resource_boundary=memory,cpu' | %w(WorkerA WorkerB WorkerC) - 'resource_boundary=memory|resource_boundary=cpu' | %w(WorkerA WorkerB WorkerC) - 'resource_boundary!=memory,cpu' | %w(WorkerA2) + 'resource_boundary=memory' | %w[WorkerB WorkerC] + 'resource_boundary=memory,cpu' | %w[WorkerA WorkerB WorkerC] + 'resource_boundary=memory|resource_boundary=cpu' | %w[WorkerA WorkerB WorkerC] + 'resource_boundary!=memory,cpu' | %w[WorkerA2] # tags - 'tags=no_disk_io' | %w(WorkerA WorkerB) - 'tags=no_disk_io,git_access' | %w(WorkerA WorkerA2 WorkerB) - 'tags=no_disk_io|tags=git_access' | %w(WorkerA WorkerA2 WorkerB) - 'tags=no_disk_io&tags=git_access' | %w(WorkerA) - 'tags!=no_disk_io' | %w(WorkerA2 WorkerC) - 'tags!=no_disk_io,git_access' | %w(WorkerC) + 'tags=no_disk_io' | %w[WorkerA WorkerB] + 'tags=no_disk_io,git_access' | %w[WorkerA WorkerA2 WorkerB] + 'tags=no_disk_io|tags=git_access' | %w[WorkerA WorkerA2 WorkerB] + 'tags=no_disk_io&tags=git_access' | %w[WorkerA] + 'tags!=no_disk_io' | %w[WorkerA2 WorkerC] + 'tags!=no_disk_io,git_access' | %w[WorkerC] 'tags=unknown_tag' | [] - 'tags!=no_disk_io' | %w(WorkerA2 WorkerC) - 'tags!=no_disk_io,git_access' | %w(WorkerC) - 'tags!=unknown_tag' | %w(WorkerA WorkerA2 WorkerB WorkerC) + 'tags!=no_disk_io' | %w[WorkerA2 WorkerC] + 'tags!=no_disk_io,git_access' | %w[WorkerC] + 'tags!=unknown_tag' | %w[WorkerA WorkerA2 WorkerB WorkerC] # combinations - 'feature_category=category_a&urgency=high' | %w(WorkerA2) - 'feature_category=category_a&urgency=high|feature_category=category_c' | %w(WorkerA2 WorkerC) + 'feature_category=category_a&urgency=high' | %w[WorkerA2] + 'feature_category=category_a&urgency=high|feature_category=category_c' | %w[WorkerA2 WorkerC] # Match all - '*' | %w(WorkerA WorkerA2 WorkerB WorkerC) + '*' | %w[WorkerA WorkerA2 WorkerB WorkerC] end with_them do diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb index 4550ccc2fff..172c4f27900 100644 --- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb +++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb @@ -181,7 +181,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do it 'logs without created_at and enqueued_at fields' do travel_to(timestamp) do - excluded_fields = %w(created_at enqueued_at args scheduling_latency_s) + excluded_fields = %w[created_at enqueued_at args scheduling_latency_s] expect(logger).to receive(:info).with(start_payload.except(*excluded_fields)).ordered expect(logger).to receive(:info).with(end_payload.except(*excluded_fields)).ordered diff --git a/spec/lib/gitlab/sidekiq_middleware/worker_context/client_spec.rb b/spec/lib/gitlab/sidekiq_middleware/worker_context/client_spec.rb index 4fbc64a45d6..0f8d84d13ec 100644 --- a/spec/lib/gitlab/sidekiq_middleware/worker_context/client_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/worker_context/client_spec.rb @@ -73,7 +73,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::WorkerContext::Client do 'job2' => build_stubbed(:user, username: 'user-2') } TestWithContextWorker.bulk_perform_async_with_contexts( - %w(job1 job2), + %w[job1 job2], arguments_proc: -> (name) { [name, 1, 2, 3] }, context_proc: -> (name) { { user: user_per_job[name] } } ) @@ -88,7 +88,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::WorkerContext::Client do context 'when the feature category is set in the context_proc' do it 'takes the feature category from the worker, not the caller' do TestWithContextWorker.bulk_perform_async_with_contexts( - %w(job1 job2), + %w[job1 job2], arguments_proc: -> (name) { [name, 1, 2, 3] }, context_proc: -> (_) { { feature_category: 'code_review' } } ) @@ -102,7 +102,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::WorkerContext::Client do it 'takes the feature category from the caller if the worker is not owned' do TestNotOwnedWithContextWorker.bulk_perform_async_with_contexts( - %w(job1 job2), + %w[job1 job2], arguments_proc: -> (name) { [name, 1, 2, 3] }, context_proc: -> (_) { { feature_category: 'code_review' } } ) @@ -125,7 +125,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::WorkerContext::Client do it 'takes the feature category from the worker, not the caller' do Gitlab::ApplicationContext.with_context(feature_category: 'system_access') do TestWithContextWorker.bulk_perform_async_with_contexts( - %w(job1 job2), + %w[job1 job2], arguments_proc: -> (name) { [name, 1, 2, 3] }, context_proc: -> (_) { {} } ) @@ -141,7 +141,7 @@ RSpec.describe Gitlab::SidekiqMiddleware::WorkerContext::Client do it 'takes the feature category from the caller if the worker is not owned' do Gitlab::ApplicationContext.with_context(feature_category: 'system_access') do TestNotOwnedWithContextWorker.bulk_perform_async_with_contexts( - %w(job1 job2), + %w[job1 job2], arguments_proc: -> (name) { [name, 1, 2, 3] }, context_proc: -> (_) { {} } ) diff --git a/spec/lib/gitlab/sidekiq_status_spec.rb b/spec/lib/gitlab/sidekiq_status_spec.rb index 7f1504a8df9..a555e6a828a 100644 --- a/spec/lib/gitlab/sidekiq_status_spec.rb +++ b/spec/lib/gitlab/sidekiq_status_spec.rb @@ -55,13 +55,13 @@ RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues, :clean_gitlab_ describe '.all_completed?' do it 'returns true if all jobs have been completed' do - expect(described_class.all_completed?(%w(123))).to eq(true) + expect(described_class.all_completed?(%w[123])).to eq(true) end it 'returns false if a job has not yet been completed' do described_class.set('123') - expect(described_class.all_completed?(%w(123 456))).to eq(false) + expect(described_class.all_completed?(%w[123 456])).to eq(false) end end @@ -79,40 +79,40 @@ RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues, :clean_gitlab_ describe '.num_running' do it 'returns 0 if all jobs have been completed' do - expect(described_class.num_running(%w(123))).to eq(0) + expect(described_class.num_running(%w[123])).to eq(0) end it 'returns 2 if two jobs are still running' do described_class.set('123') described_class.set('456') - expect(described_class.num_running(%w(123 456 789))).to eq(2) + expect(described_class.num_running(%w[123 456 789])).to eq(2) end end describe '.num_completed' do it 'returns 1 if all jobs have been completed' do - expect(described_class.num_completed(%w(123))).to eq(1) + expect(described_class.num_completed(%w[123])).to eq(1) end it 'returns 1 if a job has not yet been completed' do described_class.set('123') described_class.set('456') - expect(described_class.num_completed(%w(123 456 789))).to eq(1) + expect(described_class.num_completed(%w[123 456 789])).to eq(1) end end describe '.completed_jids' do it 'returns the completed job' do - expect(described_class.completed_jids(%w(123))).to eq(['123']) + expect(described_class.completed_jids(%w[123])).to eq(['123']) end it 'returns only the jobs completed' do described_class.set('123') described_class.set('456') - expect(described_class.completed_jids(%w(123 456 789))).to eq(['789']) + expect(described_class.completed_jids(%w[123 456 789])).to eq(['789']) end end @@ -122,7 +122,7 @@ RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues, :clean_gitlab_ described_class.set('456') described_class.unset('123') - expect(described_class.job_status(%w(123 456 789))).to eq([false, true, false]) + expect(described_class.job_status(%w[123 456 789])).to eq([false, true, false]) end it 'handles an empty array' do @@ -140,7 +140,7 @@ RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues, :clean_gitlab_ expect(Gitlab::Redis::SidekiqStatus).to receive(:with).and_call_original expect(Sidekiq).not_to receive(:redis) - described_class.job_status(%w(123 456 789)) + described_class.job_status(%w[123 456 789]) end it_behaves_like 'tracking status in redis' @@ -160,7 +160,7 @@ RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues, :clean_gitlab_ expect(Sidekiq).to receive(:redis).and_call_original expect(Gitlab::Redis::SidekiqStatus).not_to receive(:with) - described_class.job_status(%w(123 456 789)) + described_class.job_status(%w[123 456 789]) end it_behaves_like 'tracking status in redis' diff --git a/spec/lib/gitlab/ssh_public_key_spec.rb b/spec/lib/gitlab/ssh_public_key_spec.rb index d4b0b1ea53b..df9f04eb7a0 100644 --- a/spec/lib/gitlab/ssh_public_key_spec.rb +++ b/spec/lib/gitlab/ssh_public_key_spec.rb @@ -87,28 +87,28 @@ RSpec.describe Gitlab::SSHPublicKey, lib: true, fips_mode: false do describe '.supported_algorithms' do it 'returns all supported algorithms' do expect(described_class.supported_algorithms).to eq( - %w( + %w[ ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519 sk-ecdsa-sha2-nistp256@openssh.com sk-ssh-ed25519@openssh.com - ) + ] ) end context 'FIPS mode', :fips_mode do it 'returns all supported algorithms' do expect(described_class.supported_algorithms).to eq( - %w( + %w[ ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519 sk-ecdsa-sha2-nistp256@openssh.com sk-ssh-ed25519@openssh.com - ) + ] ) end end @@ -117,12 +117,12 @@ RSpec.describe Gitlab::SSHPublicKey, lib: true, fips_mode: false do describe '.supported_algorithms_for_name' do where(:name, :algorithms) do [ - [:rsa, %w(ssh-rsa)], - [:dsa, %w(ssh-dss)], - [:ecdsa, %w(ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521)], - [:ed25519, %w(ssh-ed25519)], - [:ecdsa_sk, %w(sk-ecdsa-sha2-nistp256@openssh.com)], - [:ed25519_sk, %w(sk-ssh-ed25519@openssh.com)] + [:rsa, %w[ssh-rsa]], + [:dsa, %w[ssh-dss]], + [:ecdsa, %w[ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521]], + [:ed25519, %w[ssh-ed25519]], + [:ecdsa_sk, %w[sk-ecdsa-sha2-nistp256@openssh.com]], + [:ed25519_sk, %w[sk-ssh-ed25519@openssh.com]] ] end @@ -136,12 +136,12 @@ RSpec.describe Gitlab::SSHPublicKey, lib: true, fips_mode: false do context 'FIPS mode', :fips_mode do where(:name, :algorithms) do [ - [:rsa, %w(ssh-rsa)], - [:dsa, %w(ssh-dss)], - [:ecdsa, %w(ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521)], - [:ed25519, %w(ssh-ed25519)], - [:ecdsa_sk, %w(sk-ecdsa-sha2-nistp256@openssh.com)], - [:ed25519_sk, %w(sk-ssh-ed25519@openssh.com)] + [:rsa, %w[ssh-rsa]], + [:dsa, %w[ssh-dss]], + [:ecdsa, %w[ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521]], + [:ed25519, %w[ssh-ed25519]], + [:ecdsa_sk, %w[sk-ecdsa-sha2-nistp256@openssh.com]], + [:ed25519_sk, %w[sk-ssh-ed25519@openssh.com]] ] end @@ -194,7 +194,7 @@ RSpec.describe Gitlab::SSHPublicKey, lib: true, fips_mode: false do context 'with a valid SSH key' do where(:factory) do - %i(rsa_key_2048 + %i[rsa_key_2048 rsa_key_4096 rsa_key_5120 rsa_key_8192 @@ -202,7 +202,7 @@ RSpec.describe Gitlab::SSHPublicKey, lib: true, fips_mode: false do ecdsa_key_256 ed25519_key_256 ecdsa_sk_key_256 - ed25519_sk_key_256) + ed25519_sk_key_256] end with_them do diff --git a/spec/lib/gitlab/string_range_marker_spec.rb b/spec/lib/gitlab/string_range_marker_spec.rb index 2ababd6a938..fcee64bc01c 100644 --- a/spec/lib/gitlab/string_range_marker_spec.rb +++ b/spec/lib/gitlab/string_range_marker_spec.rb @@ -14,10 +14,10 @@ RSpec.describe Gitlab::StringRangeMarker do end context "when the rich text is html safe" do - let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def"><def></span>}.html_safe } + let(:rich) { %(<span class="abc">abc</span><span class="space"> </span><span class="def"><def></span>).html_safe } it 'marks the inline diffs' do - expect(mark_diff(rich)).to eq(%{<span class="abc">abLEFTcRIGHT</span><span class="space">LEFT RIGHT</span><span class="def">LEFT<dRIGHTef></span>}) + expect(mark_diff(rich)).to eq(%(<span class="abc">abLEFTcRIGHT</span><span class="space">LEFT RIGHT</span><span class="def">LEFT<dRIGHTef></span>)) expect(mark_diff(rich)).to be_html_safe end end @@ -25,7 +25,7 @@ RSpec.describe Gitlab::StringRangeMarker do context "when the rich text is not html safe" do context 'when rich text equals raw text' do it 'marks the inline diffs' do - expect(mark_diff).to eq(%{abLEFTc <dRIGHTef>}) + expect(mark_diff).to eq(%(abLEFTc <dRIGHTef>)) expect(mark_diff).not_to be_html_safe end end @@ -34,7 +34,7 @@ RSpec.describe Gitlab::StringRangeMarker do let(:rich) { "abc <def> differs" } it 'marks the inline diffs' do - expect(mark_diff(rich)).to eq(%{abLEFTc <dRIGHTef> differs}) + expect(mark_diff(rich)).to eq(%(abLEFTc <dRIGHTef> differs)) expect(mark_diff(rich)).to be_html_safe end end diff --git a/spec/lib/gitlab/string_regex_marker_spec.rb b/spec/lib/gitlab/string_regex_marker_spec.rb index 393bfea7c6b..87df8b9baab 100644 --- a/spec/lib/gitlab/string_regex_marker_spec.rb +++ b/spec/lib/gitlab/string_regex_marker_spec.rb @@ -5,34 +5,34 @@ require 'fast_spec_helper' RSpec.describe Gitlab::StringRegexMarker do describe '#mark' do context 'with a single occurrence' do - let(:raw) { %{"name": "AFNetworking"} } - let(:rich) { %{<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"AFNetworking"</span>}.html_safe } + let(:raw) { %("name": "AFNetworking") } + let(:rich) { %(<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"AFNetworking"</span>).html_safe } subject do described_class.new(raw, rich).mark(/"[^"]+":\s*"(?<name>[^"]+)"/, group: :name) do |text, left:, right:, mode:| - %{<a href="#">#{text}</a>}.html_safe + %(<a href="#">#{text}</a>).html_safe end end it 'marks the match' do - expect(subject).to eq(%{<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"<a href="#">AFNetworking</a>"</span>}) + expect(subject).to eq(%(<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"<a href="#">AFNetworking</a>"</span>)) expect(subject).to be_html_safe end end context 'with multiple occurrences' do - let(:raw) { %{a <b> <c> d} } - let(:rich) { %{a <b> <c> d}.html_safe } + let(:raw) { %(a <b> <c> d) } + let(:rich) { %(a <b> <c> d).html_safe } let(:regexp) { /<[a-z]>/ } subject do described_class.new(raw, rich).mark(regexp) do |text, left:, right:, mode:| - %{<strong>#{text}</strong>}.html_safe + %(<strong>#{text}</strong>).html_safe end end it 'marks the matches' do - expect(subject).to eq(%{a <strong><b></strong> <strong><c></strong> d}) + expect(subject).to eq(%(a <strong><b></strong> <strong><c></strong> d)) expect(subject).to be_html_safe end @@ -40,7 +40,7 @@ RSpec.describe Gitlab::StringRegexMarker do let(:regexp) { Gitlab::UntrustedRegexp.new('<[a-z]>') } it 'marks the matches' do - expect(subject).to eq(%{a <strong><b></strong> <strong><c></strong> d}) + expect(subject).to eq(%(a <strong><b></strong> <strong><c></strong> d)) expect(subject).to be_html_safe end end diff --git a/spec/lib/gitlab/suggestions/suggestion_set_spec.rb b/spec/lib/gitlab/suggestions/suggestion_set_spec.rb index 469646986e1..298ade2e33f 100644 --- a/spec/lib/gitlab/suggestions/suggestion_set_spec.rb +++ b/spec/lib/gitlab/suggestions/suggestion_set_spec.rb @@ -114,7 +114,7 @@ RSpec.describe Gitlab::Suggestions::SuggestionSet do it 'returns an array of unique file paths associated with the suggestions' do suggestion_set = described_class.new([suggestion, suggestion2, suggestion3]) - expected_paths = %w(files/ruby/popen.rb files/ruby/regex.rb) + expected_paths = %w[files/ruby/popen.rb files/ruby/regex.rb] actual_paths = suggestion_set.file_paths diff --git a/spec/lib/gitlab/task_helpers_spec.rb b/spec/lib/gitlab/task_helpers_spec.rb index 0c43dd15e8c..448406dfb99 100644 --- a/spec/lib/gitlab/task_helpers_spec.rb +++ b/spec/lib/gitlab/task_helpers_spec.rb @@ -84,17 +84,17 @@ RSpec.describe Gitlab::TaskHelpers do describe '#run_command' do it 'runs command and return the output' do - expect(subject.run_command(%w(echo it works!))).to eq("it works!\n") + expect(subject.run_command(%w[echo it works!])).to eq("it works!\n") end it 'returns empty string when command doesnt exist' do - expect(subject.run_command(%w(nonexistentcommand with arguments))).to eq('') + expect(subject.run_command(%w[nonexistentcommand with arguments])).to eq('') end end describe '#run_command!' do it 'runs command and return the output' do - expect(subject.run_command!(%w(echo it works!))).to eq("it works!\n") + expect(subject.run_command!(%w[echo it works!])).to eq("it works!\n") end it 'returns and exception when command exit with non zero code' do diff --git a/spec/lib/gitlab/tracking/event_definition_spec.rb b/spec/lib/gitlab/tracking/event_definition_spec.rb index b27aaa35695..ab0660147e4 100644 --- a/spec/lib/gitlab/tracking/event_definition_spec.rb +++ b/spec/lib/gitlab/tracking/event_definition_spec.rb @@ -15,8 +15,8 @@ RSpec.describe Gitlab::Tracking::EventDefinition do product_stage: 'growth', product_section: 'dev', product_group: 'group::product analytics', - distribution: %w(ee ce), - tier: %w(free premium ultimate) + distribution: %w[ee ce], + tier: %w[free premium ultimate] } end @@ -49,8 +49,8 @@ RSpec.describe Gitlab::Tracking::EventDefinition do :product_stage | 1 :product_section | nil :product_group | nil - :distributions | %[be eb] - :tiers | %[pro] + :distributions | %(be eb) + :tiers | %(pro) end with_them do diff --git a/spec/lib/gitlab/url_sanitizer_spec.rb b/spec/lib/gitlab/url_sanitizer_spec.rb index 2c2ef8f13fb..6a1521d9d72 100644 --- a/spec/lib/gitlab/url_sanitizer_spec.rb +++ b/spec/lib/gitlab/url_sanitizer_spec.rb @@ -8,10 +8,10 @@ RSpec.describe Gitlab::UrlSanitizer do describe '.sanitize' do def sanitize_url(url) # We want to try with multi-line content because is how error messages are formatted - described_class.sanitize(%{ + described_class.sanitize(%( remote: Not Found fatal: repository `#{url}` not found - }) + )) end where(:input, :output) do @@ -50,7 +50,7 @@ RSpec.describe Gitlab::UrlSanitizer do false | '123://invalid:url' false | 'valid@project:url.git' false | 'valid:pass@project:url.git' - false | %w(test array) + false | %w[test array] true | 'ssh://example.com' true | 'ssh://:@example.com' true | 'ssh://foo@example.com' @@ -74,7 +74,7 @@ RSpec.describe Gitlab::UrlSanitizer do false | '123://invalid:url' false | 'valid@project:url.git' false | 'valid:pass@project:url.git' - false | %w(test array) + false | %w[test array] false | 'ssh://example.com' false | 'ssh://:@example.com' false | 'ssh://foo@example.com' diff --git a/spec/lib/gitlab/usage/metric_definition_spec.rb b/spec/lib/gitlab/usage/metric_definition_spec.rb index 51d3090c825..d57159b8a57 100644 --- a/spec/lib/gitlab/usage/metric_definition_spec.rb +++ b/spec/lib/gitlab/usage/metric_definition_spec.rb @@ -16,8 +16,8 @@ RSpec.describe Gitlab::Usage::MetricDefinition, feature_category: :service_ping product_group: 'product_analytics', time_frame: 'none', data_source: 'database', - distribution: %w(ee ce), - tier: %w(free starter premium ultimate bronze silver gold), + distribution: %w[ee ce], + tier: %w[free starter premium ultimate bronze silver gold], data_category: 'standard', removed_by_url: 'http://gdk.test' } @@ -64,7 +64,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition, feature_category: :service_ping it 'includes metrics that are not removed' do expect(described_class.not_removed.count).to eq(3) - expect(described_class.not_removed.keys).to match_array(%w(metric1 metric2 metric3)) + expect(described_class.not_removed.keys).to match_array(%w[metric1 metric2 metric3]) end end @@ -162,7 +162,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition, feature_category: :service_ping :data_source | nil :distribution | nil :distribution | 'test' - :tier | %w(test ee) + :tier | %w[test ee] :repair_issue_url | nil :removed_by_url | 1 @@ -309,8 +309,8 @@ RSpec.describe Gitlab::Usage::MetricDefinition, feature_category: :service_ping product_group: 'product_analytics', time_frame: 'none', data_source: 'database', - distribution: %w(ee ce), - tier: %w(free starter premium ultimate bronze silver gold), + distribution: %w[ee ce], + tier: %w[free starter premium ultimate bronze silver gold], data_category: 'optional' } end diff --git a/spec/lib/gitlab/usage/metric_spec.rb b/spec/lib/gitlab/usage/metric_spec.rb index a4135b143dd..42d2f394ce3 100644 --- a/spec/lib/gitlab/usage/metric_spec.rb +++ b/spec/lib/gitlab/usage/metric_spec.rb @@ -18,8 +18,8 @@ RSpec.describe Gitlab::Usage::Metric do time_frame: "all", data_source: "database", instrumentation_class: "CountIssuesMetric", - distribution: %w(ce ee), - tier: %w(free premium ultimate) + distribution: %w[ce ee], + tier: %w[free premium ultimate] } end diff --git a/spec/lib/gitlab/usage/service_ping/instrumented_payload_spec.rb b/spec/lib/gitlab/usage/service_ping/instrumented_payload_spec.rb index 9d2711c49c6..51649e389e2 100644 --- a/spec/lib/gitlab/usage/service_ping/instrumented_payload_spec.rb +++ b/spec/lib/gitlab/usage/service_ping/instrumented_payload_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Gitlab::Usage::ServicePing::InstrumentedPayload do end context 'when building service ping with values' do - let(:metrics_key_paths) { %w(counts.boards uuid redis_hll_counters.search.i_search_total_monthly) } + let(:metrics_key_paths) { %w[counts.boards uuid redis_hll_counters.search.i_search_total_monthly] } let(:expected_payload) do { counts: { boards: 0 }, @@ -26,7 +26,7 @@ RSpec.describe Gitlab::Usage::ServicePing::InstrumentedPayload do end context 'when building service ping with instrumentations' do - let(:metrics_key_paths) { %w(counts.boards uuid redis_hll_counters.search.i_search_total_monthly) } + let(:metrics_key_paths) { %w[counts.boards uuid redis_hll_counters.search.i_search_total_monthly] } let(:expected_payload) do { counts: { boards: "SELECT COUNT(\"boards\".\"id\") FROM \"boards\"" }, diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 6f188aa408e..a1564318408 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -42,7 +42,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic end it 'ensures recorded_at is set before any other usage data calculation' do - %i(alt_usage_data redis_usage_data distinct_count count).each do |method| + %i[alt_usage_data redis_usage_data distinct_count count].each do |method| expect(described_class).not_to receive(method) end expect(described_class).to receive(:recorded_at).and_raise(Exception.new('Stopped calculating recorded_at')) @@ -191,7 +191,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic omniauth: { providers: omniauth_providers } ) - allow(Devise).to receive(:omniauth_providers).and_return(%w(ldapmain ldapsecondary group_saml)) + allow(Devise).to receive(:omniauth_providers).and_return(%w[ldapmain ldapsecondary group_saml]) for_defined_days_back do user = create(:user) @@ -268,7 +268,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic for_defined_days_back do user = create(:user) - %w(gitlab_project github bitbucket bitbucket_server gitea git manifest fogbugz).each do |type| + %w[gitlab_project github bitbucket bitbucket_server gitea git manifest fogbugz].each do |type| create(:project, import_type: type, creator_id: user.id) end @@ -734,7 +734,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic subject { described_class.object_store_usage_data } it 'fetches object store config of five components' do - %w(artifacts external_diffs lfs uploads packages).each do |component| + %w[artifacts external_diffs lfs uploads packages].each do |component| expect(described_class).to receive(:object_store_config).with(component).and_return("#{component}_object_store_config") end diff --git a/spec/lib/gitlab/utils/log_limited_array_spec.rb b/spec/lib/gitlab/utils/log_limited_array_spec.rb index a55a176be48..23cca4fd791 100644 --- a/spec/lib/gitlab/utils/log_limited_array_spec.rb +++ b/spec/lib/gitlab/utils/log_limited_array_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Gitlab::Utils::LogLimitedArray do context 'when the argument is an array' do context 'when the array is under the limit' do it 'returns the array unchanged' do - expect(described_class.log_limited_array(%w(a b))).to eq(%w(a b)) + expect(described_class.log_limited_array(%w[a b])).to eq(%w[a b]) end end diff --git a/spec/lib/gitlab/webpack/graphql_known_operations_spec.rb b/spec/lib/gitlab/webpack/graphql_known_operations_spec.rb index 89cade82fe6..6c3e3b4eb69 100644 --- a/spec/lib/gitlab/webpack/graphql_known_operations_spec.rb +++ b/spec/lib/gitlab/webpack/graphql_known_operations_spec.rb @@ -30,7 +30,7 @@ RSpec.describe Gitlab::Webpack::GraphqlKnownOperations do 2.times { ::Gitlab::Webpack::GraphqlKnownOperations.load } - expect(::Gitlab::Webpack::GraphqlKnownOperations.load).to eq(%w(hello world test)) + expect(::Gitlab::Webpack::GraphqlKnownOperations.load).to eq(%w[hello world test]) end end diff --git a/spec/lib/gitlab/wiki_pages/front_matter_parser_spec.rb b/spec/lib/gitlab/wiki_pages/front_matter_parser_spec.rb index 3152dc2ad2f..3d165f7d830 100644 --- a/spec/lib/gitlab/wiki_pages/front_matter_parser_spec.rb +++ b/spec/lib/gitlab/wiki_pages/front_matter_parser_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Gitlab::WikiPages::FrontMatterParser do end def have_correct_front_matter - include(a: 1, b: 2, c: %w(foo bar)) + include(a: 1, b: 2, c: %w[foo bar]) end describe '#parse' do diff --git a/spec/lib/object_storage/config_spec.rb b/spec/lib/object_storage/config_spec.rb index 412fcb9b6b8..bf9aeb51cda 100644 --- a/spec/lib/object_storage/config_spec.rb +++ b/spec/lib/object_storage/config_spec.rb @@ -155,7 +155,7 @@ RSpec.describe ObjectStorage::Config, feature_category: :shared do it { expect(subject.aws_server_side_encryption_enabled?).to be true } it { expect(subject.server_side_encryption).to eq('AES256') } it { expect(subject.server_side_encryption_kms_key_id).to eq('arn:aws:12345') } - it { expect(subject.fog_attributes.keys).to match_array(%w(x-amz-server-side-encryption x-amz-server-side-encryption-aws-kms-key-id)) } + it { expect(subject.fog_attributes.keys).to match_array(%w[x-amz-server-side-encryption x-amz-server-side-encryption-aws-kms-key-id]) } end context 'with only server side encryption enabled' do diff --git a/spec/lib/object_storage/direct_upload_spec.rb b/spec/lib/object_storage/direct_upload_spec.rb index 3a42e6ebd09..5df295e73d7 100644 --- a/spec/lib/object_storage/direct_upload_spec.rb +++ b/spec/lib/object_storage/direct_upload_spec.rb @@ -123,7 +123,7 @@ RSpec.describe ObjectStorage::DirectUpload, feature_category: :shared do expect(s3_config[:Region]).to eq(region) expect(s3_config[:PathStyle]).to eq(path_style) expect(s3_config[:UseIamProfile]).to eq(use_iam_profile) - expect(s3_config.keys).not_to include(%i(ServerSideEncryption SSEKMSKeyID)) + expect(s3_config.keys).not_to include(%i[ServerSideEncryption SSEKMSKeyID]) end context 'when no region is specified' do diff --git a/spec/lib/rouge/formatters/html_gitlab_spec.rb b/spec/lib/rouge/formatters/html_gitlab_spec.rb index 6fc1b395fc8..5e5075b72b8 100644 --- a/spec/lib/rouge/formatters/html_gitlab_spec.rb +++ b/spec/lib/rouge/formatters/html_gitlab_spec.rb @@ -15,14 +15,14 @@ RSpec.describe Rouge::Formatters::HTMLGitlab, feature_category: :source_code_man let(:options) { { tag: lang, ellipsis_indexes: [0], ellipsis_svg: "svg_icon" } } it 'returns highlighted ruby code with svg' do - code = %q{<span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">hello</span><span class="gl-px-2 gl-rounded-base gl-mx-2 gl-bg-gray-100 gl-cursor-help has-tooltip" title="Content has been trimmed">svg_icon</span></span>} + code = %q(<span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">hello</span><span class="gl-px-2 gl-rounded-base gl-mx-2 gl-bg-gray-100 gl-cursor-help has-tooltip" title="Content has been trimmed">svg_icon</span></span>) is_expected.to eq(code) end end it 'returns highlighted ruby code' do - code = %q{<span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">hello</span></span>} + code = %q(<span id="LC1" class="line" lang="ruby"><span class="k">def</span> <span class="nf">hello</span></span>) is_expected.to eq(code) end @@ -31,7 +31,7 @@ RSpec.describe Rouge::Formatters::HTMLGitlab, feature_category: :source_code_man let(:options) { {} } it 'returns highlighted code without language' do - code = %q{<span id="LC1" class="line" lang=""><span class="k">def</span> <span class="nf">hello</span></span>} + code = %q(<span id="LC1" class="line" lang=""><span class="k">def</span> <span class="nf">hello</span></span>) is_expected.to eq(code) end @@ -41,7 +41,7 @@ RSpec.describe Rouge::Formatters::HTMLGitlab, feature_category: :source_code_man let(:options) { { tag: lang, line_number: 10 } } it 'returns highlighted ruby code with correct line number' do - code = %q{<span id="LC10" class="line" lang="ruby"><span class="k">def</span> <span class="nf">hello</span></span>} + code = %q(<span id="LC10" class="line" lang="ruby"><span class="k">def</span> <span class="nf">hello</span></span>) is_expected.to eq(code) end @@ -64,7 +64,7 @@ RSpec.describe Rouge::Formatters::HTMLGitlab, feature_category: :source_code_man it 'highlights the control characters' do message = "Potentially unwanted character detected: Unicode BiDi Control" - is_expected.to include(%{<span class="unicode-bidi has-tooltip" data-toggle="tooltip" title="#{message}">}).exactly(4).times + is_expected.to include(%(<span class="unicode-bidi has-tooltip" data-toggle="tooltip" title="#{message}">)).exactly(4).times end end diff --git a/spec/lib/safe_zip/entry_spec.rb b/spec/lib/safe_zip/entry_spec.rb index 8d49e2bcece..9a068b255dd 100644 --- a/spec/lib/safe_zip/entry_spec.rb +++ b/spec/lib/safe_zip/entry_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' RSpec.describe SafeZip::Entry do let(:target_path) { Dir.mktmpdir('safe-zip') } - let(:directories) { %w(public folder/with/subfolder) } - let(:files) { %w(public/index.html public/assets/image.png) } + let(:directories) { %w[public folder/with/subfolder] } + let(:files) { %w[public/index.html public/assets/image.png] } let(:params) { SafeZip::ExtractParams.new(directories: directories, files: files, to: target_path) } let(:entry) { described_class.new(zip_archive, zip_entry, params) } @@ -52,7 +52,7 @@ RSpec.describe SafeZip::Entry do subject { entry.extract } context 'when entry does not match the filtered directories' do - let(:directories) { %w(public folder/with/subfolder) } + let(:directories) { %w[public folder/with/subfolder] } let(:files) { [] } using RSpec::Parameterized::TableSyntax @@ -76,7 +76,7 @@ RSpec.describe SafeZip::Entry do context 'when entry does not match the filtered files' do let(:directories) { [] } - let(:files) { %w(public/index.html public/assets/image.png) } + let(:files) { %w[public/index.html public/assets/image.png] } using RSpec::Parameterized::TableSyntax diff --git a/spec/lib/safe_zip/extract_params_spec.rb b/spec/lib/safe_zip/extract_params_spec.rb index 0ebfb7430c5..b0d787e09d5 100644 --- a/spec/lib/safe_zip/extract_params_spec.rb +++ b/spec/lib/safe_zip/extract_params_spec.rb @@ -6,8 +6,8 @@ RSpec.describe SafeZip::ExtractParams do let(:target_path) { Dir.mktmpdir("safe-zip") } let(:real_target_path) { File.realpath(target_path) } let(:params) { described_class.new(directories: directories, files: files, to: target_path) } - let(:directories) { %w(public folder/with/subfolder) } - let(:files) { %w(public/index.html public/assets/image.png) } + let(:directories) { %w[public folder/with/subfolder] } + let(:files) { %w[public/index.html public/assets/image.png] } after do FileUtils.remove_entry_secure(target_path) diff --git a/spec/lib/safe_zip/extract_spec.rb b/spec/lib/safe_zip/extract_spec.rb index c727475e271..fa8a922beef 100644 --- a/spec/lib/safe_zip/extract_spec.rb +++ b/spec/lib/safe_zip/extract_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' RSpec.describe SafeZip::Extract do let(:target_path) { Dir.mktmpdir('safe-zip') } - let(:directories) { %w(public) } - let(:files) { %w(public/index.html) } + let(:directories) { %w[public] } + let(:files) { %w[public/index.html] } let(:object) { described_class.new(archive) } let(:archive) { Rails.root.join('spec', 'fixtures', 'safe_zip', archive_name) } @@ -47,7 +47,7 @@ RSpec.describe SafeZip::Extract do end end - %w(valid-simple.zip valid-symlinks-first.zip valid-non-writeable.zip).each do |name| + %w[valid-simple.zip valid-symlinks-first.zip valid-non-writeable.zip].each do |name| context "when using #{name} archive" do let(:archive_name) { name } @@ -74,7 +74,7 @@ RSpec.describe SafeZip::Extract do context 'when no matching directories are found' do let(:archive_name) { 'valid-simple.zip' } - let(:directories) { %w(non/existing) } + let(:directories) { %w[non/existing] } let(:error_message) { 'No entries extracted' } subject { object.extract(directories: directories, to: target_path) } @@ -84,7 +84,7 @@ RSpec.describe SafeZip::Extract do context 'when no matching files are found' do let(:archive_name) { 'valid-simple.zip' } - let(:files) { %w(non/existing) } + let(:files) { %w[non/existing] } let(:error_message) { 'No entries extracted' } subject { object.extract(files: files, to: target_path) } diff --git a/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb b/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb index 5b1db66beb0..af61d9c8261 100644 --- a/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/container_scanning_build_action_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Security::CiConfiguration::ContainerScanningBuildAction do context 'template includes are an array' do let(:gitlab_ci_content) do - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists" }, "include" => [{ "template" => "existing.yml" }] } end @@ -52,7 +52,7 @@ RSpec.describe Security::CiConfiguration::ContainerScanningBuildAction do context 'template include is not an array' do let(:gitlab_ci_content) do - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists" }, "include" => { "template" => "existing.yml" } } end @@ -91,7 +91,7 @@ RSpec.describe Security::CiConfiguration::ContainerScanningBuildAction do context 'container_scanning template include are an array' do let(:gitlab_ci_content) do - { "stages" => %w(test), + { "stages" => %w[test], "variables" => { "RANDOM" => "make sure this persists" }, "include" => [{ "template" => "Jobs/Container-Scanning.gitlab-ci.yml" }] } end @@ -104,7 +104,7 @@ RSpec.describe Security::CiConfiguration::ContainerScanningBuildAction do context 'container_scanning template include is not an array' do let(:gitlab_ci_content) do - { "stages" => %w(test), + { "stages" => %w[test], "variables" => { "RANDOM" => "make sure this persists" }, "include" => { "template" => "Jobs/Container-Scanning.gitlab-ci.yml" } } end diff --git a/spec/lib/security/ci_configuration/sast_build_action_spec.rb b/spec/lib/security/ci_configuration/sast_build_action_spec.rb index 381ea60e7f5..fe504e2b278 100644 --- a/spec/lib/security/ci_configuration/sast_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/sast_build_action_spec.rb @@ -218,47 +218,47 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do end def existing_gitlab_ci_and_template_array_without_sast - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "security" }, "include" => [{ "template" => "existing.yml" }] } end def existing_gitlab_ci_and_single_template_with_sast_and_default_stage - { "stages" => %w(test), + { "stages" => %w[test], "variables" => { "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "test" }, "include" => { "template" => "Security/SAST.gitlab-ci.yml" } } end def existing_gitlab_ci_and_single_template_without_sast - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "security" }, "include" => { "template" => "existing.yml" } } end def existing_gitlab_ci_with_no_variables - { "stages" => %w(test security), + { "stages" => %w[test security], "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "security" }, "include" => [{ "template" => "Security/SAST.gitlab-ci.yml" }] } end def existing_gitlab_ci_with_no_sast_section - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "include" => [{ "template" => "Security/SAST.gitlab-ci.yml" }] } end def existing_gitlab_ci_with_no_sast_variables - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "stage" => "security" }, "include" => [{ "template" => "Security/SAST.gitlab-ci.yml" }] } end def existing_gitlab_ci - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "bad_prefix" }, "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "security" }, "include" => [{ "template" => "Security/SAST.gitlab-ci.yml" }] } diff --git a/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb b/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb index 7b2a0d22918..fcee34d833b 100644 --- a/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/sast_iac_build_action_spec.rb @@ -34,7 +34,7 @@ RSpec.describe Security::CiConfiguration::SastIacBuildAction do context 'template includes are an array' do let(:gitlab_ci_content) do - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists" }, "include" => [{ "template" => "existing.yml" }] } end @@ -47,7 +47,7 @@ RSpec.describe Security::CiConfiguration::SastIacBuildAction do context 'template include is not an array' do let(:gitlab_ci_content) do - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists" }, "include" => { "template" => "existing.yml" } } end @@ -80,7 +80,7 @@ RSpec.describe Security::CiConfiguration::SastIacBuildAction do context 'secret_detection template include are an array' do let(:gitlab_ci_content) do - { "stages" => %w(test), + { "stages" => %w[test], "variables" => { "RANDOM" => "make sure this persists" }, "include" => [{ "template" => "Security/SAST-IaC.latest.gitlab-ci.yml" }] } end @@ -93,7 +93,7 @@ RSpec.describe Security::CiConfiguration::SastIacBuildAction do context 'secret_detection template include is not an array' do let(:gitlab_ci_content) do - { "stages" => %w(test), + { "stages" => %w[test], "variables" => { "RANDOM" => "make sure this persists" }, "include" => { "template" => "Security/SAST-IaC.latest.gitlab-ci.yml" } } end diff --git a/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb b/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb index 4d9860ca4a5..64323ce71f3 100644 --- a/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/secret_detection_build_action_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Security::CiConfiguration::SecretDetectionBuildAction do context 'template includes are an array' do let(:gitlab_ci_content) do - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists" }, "include" => [{ "template" => "existing.yml" }] } end @@ -46,7 +46,7 @@ RSpec.describe Security::CiConfiguration::SecretDetectionBuildAction do context 'template include is not an array' do let(:gitlab_ci_content) do - { "stages" => %w(test security), + { "stages" => %w[test security], "variables" => { "RANDOM" => "make sure this persists" }, "include" => { "template" => "existing.yml" } } end @@ -79,7 +79,7 @@ RSpec.describe Security::CiConfiguration::SecretDetectionBuildAction do context 'secret_detection template include are an array' do let(:gitlab_ci_content) do - { "stages" => %w(test), + { "stages" => %w[test], "variables" => { "RANDOM" => "make sure this persists" }, "include" => [{ "template" => "Security/Secret-Detection.gitlab-ci.yml" }] } end @@ -92,7 +92,7 @@ RSpec.describe Security::CiConfiguration::SecretDetectionBuildAction do context 'secret_detection template include is not an array' do let(:gitlab_ci_content) do - { "stages" => %w(test), + { "stages" => %w[test], "variables" => { "RANDOM" => "make sure this persists" }, "include" => { "template" => "Security/Secret-Detection.gitlab-ci.yml" } } end diff --git a/spec/lib/sidebars/menu_spec.rb b/spec/lib/sidebars/menu_spec.rb index e59a8cd2163..5e22777e256 100644 --- a/spec/lib/sidebars/menu_spec.rb +++ b/spec/lib/sidebars/menu_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Sidebars::Menu, feature_category: :navigation do describe '#all_active_routes' do it 'gathers all active routes of items and the current menu' do - menu.add_item(Sidebars::MenuItem.new(title: 'foo1', link: 'foo1', active_routes: { path: %w(bar test) })) + menu.add_item(Sidebars::MenuItem.new(title: 'foo1', link: 'foo1', active_routes: { path: %w[bar test] })) menu.add_item(Sidebars::MenuItem.new(title: 'foo2', link: 'foo2', active_routes: { controller: 'fooc' })) menu.add_item(Sidebars::MenuItem.new(title: 'foo3', link: 'foo3', active_routes: { controller: 'barc' })) menu.add_item(nil_menu_item) @@ -18,7 +18,7 @@ RSpec.describe Sidebars::Menu, feature_category: :navigation do allow(menu).to receive(:active_routes).and_return({ path: 'foo' }) expect(menu).to receive(:renderable_items).and_call_original - expect(menu.all_active_routes).to eq({ path: %w(foo bar test), controller: %w(fooc barc) }) + expect(menu.all_active_routes).to eq({ path: %w[foo bar test], controller: %w[fooc barc] }) end end diff --git a/spec/lib/system_check/orphans/namespace_check_spec.rb b/spec/lib/system_check/orphans/namespace_check_spec.rb index e764c2313cd..3964068b20c 100644 --- a/spec/lib/system_check/orphans/namespace_check_spec.rb +++ b/spec/lib/system_check/orphans/namespace_check_spec.rb @@ -12,10 +12,10 @@ RSpec.describe SystemCheck::Orphans::NamespaceCheck, :silence_stdout do describe '#multi_check' do context 'all orphans' do - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 repos/@hashed] } it 'prints list of all orphaned namespaces except @hashed' do - expect_list_of_orphans(%w(orphan1 orphan2)) + expect_list_of_orphans(%w[orphan1 orphan2]) subject.multi_check end @@ -23,10 +23,10 @@ RSpec.describe SystemCheck::Orphans::NamespaceCheck, :silence_stdout do context 'few orphans with existing namespace' do let!(:first_level) { create(:group, path: 'my-namespace') } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed] } it 'prints list of orphaned namespaces' do - expect_list_of_orphans(%w(orphan1 orphan2)) + expect_list_of_orphans(%w[orphan1 orphan2]) subject.multi_check end @@ -35,17 +35,17 @@ RSpec.describe SystemCheck::Orphans::NamespaceCheck, :silence_stdout do context 'few orphans with existing namespace and parents with same name as orphans' do let!(:first_level) { create(:group, path: 'my-namespace') } let!(:second_level) { create(:group, path: 'second-level', parent: first_level) } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed] } it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do - expect_list_of_orphans(%w(orphan1 orphan2 second-level)) + expect_list_of_orphans(%w[orphan1 orphan2 second-level]) subject.multi_check end end context 'no orphans' do - let(:disk_namespaces) { %w(@hashed) } + let(:disk_namespaces) { %w[@hashed] } it 'prints an empty list ignoring @hashed' do expect_list_of_orphans([]) diff --git a/spec/lib/system_check/orphans/repository_check_spec.rb b/spec/lib/system_check/orphans/repository_check_spec.rb index 91b48969cc1..0504e133ab9 100644 --- a/spec/lib/system_check/orphans/repository_check_spec.rb +++ b/spec/lib/system_check/orphans/repository_check_spec.rb @@ -13,11 +13,11 @@ RSpec.describe SystemCheck::Orphans::RepositoryCheck, :silence_stdout do describe '#multi_check' do context 'all orphans' do - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) } - let(:disk_repositories) { %w(repo1.git repo2.git) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 repos/@hashed] } + let(:disk_repositories) { %w[repo1.git repo2.git] } it 'prints list of all orphaned namespaces except @hashed' do - expect_list_of_orphans(%w(orphan1/repo1.git orphan1/repo2.git orphan2/repo1.git orphan2/repo2.git)) + expect_list_of_orphans(%w[orphan1/repo1.git orphan1/repo2.git orphan2/repo1.git orphan2/repo2.git]) subject.multi_check end @@ -26,11 +26,11 @@ RSpec.describe SystemCheck::Orphans::RepositoryCheck, :silence_stdout do context 'few orphans with existing namespace' do let!(:first_level) { create(:group, path: 'my-namespace') } let!(:project) { create(:project, path: 'repo', namespace: first_level) } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) } - let(:disk_repositories) { %w(repo.git) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed] } + let(:disk_repositories) { %w[repo.git] } it 'prints list of orphaned namespaces' do - expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git)) + expect_list_of_orphans(%w[orphan1/repo.git orphan2/repo.git]) subject.multi_check end @@ -40,19 +40,19 @@ RSpec.describe SystemCheck::Orphans::RepositoryCheck, :silence_stdout do let!(:first_level) { create(:group, path: 'my-namespace') } let!(:second_level) { create(:group, path: 'second-level', parent: first_level) } let!(:project) { create(:project, path: 'repo', namespace: first_level) } - let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) } - let(:disk_repositories) { %w(repo.git) } + let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed] } + let(:disk_repositories) { %w[repo.git] } it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do - expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git second-level/repo.git)) + expect_list_of_orphans(%w[orphan1/repo.git orphan2/repo.git second-level/repo.git]) subject.multi_check end end context 'no orphans' do - let(:disk_namespaces) { %w(@hashed) } - let(:disk_repositories) { %w(repo.git) } + let(:disk_namespaces) { %w[@hashed] } + let(:disk_repositories) { %w[repo.git] } it 'prints an empty list ignoring @hashed' do expect_list_of_orphans([]) diff --git a/spec/lib/system_check/sidekiq_check_spec.rb b/spec/lib/system_check/sidekiq_check_spec.rb index ff4eece8f7c..efd5414294a 100644 --- a/spec/lib/system_check/sidekiq_check_spec.rb +++ b/spec/lib/system_check/sidekiq_check_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe SystemCheck::SidekiqCheck do describe '#multi_check' do def stub_ps_output(output) - allow(Gitlab::Popen).to receive(:popen).with(%w(ps uxww)).and_return([output, nil]) + allow(Gitlab::Popen).to receive(:popen).with(%w[ps uxww]).and_return([output, nil]) end def expect_check_output(matcher) diff --git a/spec/lib/unnested_in_filters/dsl_spec.rb b/spec/lib/unnested_in_filters/dsl_spec.rb index bce4c88f94c..9f1552b02ec 100644 --- a/spec/lib/unnested_in_filters/dsl_spec.rb +++ b/spec/lib/unnested_in_filters/dsl_spec.rb @@ -12,7 +12,7 @@ RSpec.describe UnnestedInFilters::Dsl do end describe '#exists?' do - let(:states) { %w(active banned) } + let(:states) { %w[active banned] } subject { test_model.where(state: states).use_unnested_filters.exists? } diff --git a/spec/lib/unnested_in_filters/rewriter_spec.rb b/spec/lib/unnested_in_filters/rewriter_spec.rb index ea561c42993..945a50ce2e8 100644 --- a/spec/lib/unnested_in_filters/rewriter_spec.rb +++ b/spec/lib/unnested_in_filters/rewriter_spec.rb @@ -26,7 +26,7 @@ RSpec.describe UnnestedInFilters::Rewriter do context 'when the given relation has an `IN` predicate' do context 'when there is no index coverage for the used columns' do - let(:relation) { User.where(username: %w(user_1 user_2), state: :active) } + let(:relation) { User.where(username: %w[user_1 user_2], state: :active) } it { is_expected.to be_falsey } end @@ -37,7 +37,7 @@ RSpec.describe UnnestedInFilters::Rewriter do it { is_expected.to be_truthy } context 'when there is an ordering' do - let(:relation) { User.where(state: %w(active blocked banned)).order(order).limit(2) } + let(:relation) { User.where(state: %w[active blocked banned]).order(order).limit(2) } context 'when the order is an Arel node' do let(:order) { { user_type: :desc } } @@ -67,7 +67,7 @@ RSpec.describe UnnestedInFilters::Rewriter do describe '#rewrite' do let(:recorded_queries) { ActiveRecord::QueryRecorder.new { rewriter.rewrite.load } } - let(:relation) { User.where(state: :active, user_type: %i(support_bot alert_bot)).limit(2) } + let(:relation) { User.where(state: :active, user_type: %i[support_bot alert_bot]).limit(2) } let(:users_select) { 'SELECT "users".*' } let(:users_select_with_ignored_columns) { 'SELECT ("users"."\w+", )+("users"."\w+")' } @@ -101,7 +101,7 @@ RSpec.describe UnnestedInFilters::Rewriter do end context 'when the relation has a subquery' do - let(:relation) { User.where(state: User.select(:state), user_type: %i(support_bot alert_bot)).limit(1) } + let(:relation) { User.where(state: User.select(:state), user_type: %i[support_bot alert_bot]).limit(1) } let(:users_unnest) do 'FROM @@ -127,7 +127,7 @@ RSpec.describe UnnestedInFilters::Rewriter do end context 'when there is an order' do - let(:relation) { User.where(state: %w(active blocked banned)).order(order).limit(2) } + let(:relation) { User.where(state: %w[active blocked banned]).order(order).limit(2) } let(:users_unnest) do 'FROM @@ -177,7 +177,7 @@ RSpec.describe UnnestedInFilters::Rewriter do end context 'when the combined attributes include the primary key' do - let(:relation) { User.where(user_type: %i(support_bot alert_bot)).order(id: :desc).limit(2) } + let(:relation) { User.where(user_type: %i[support_bot alert_bot]).order(id: :desc).limit(2) } let(:users_where) do 'FROM diff --git a/spec/models/ml/model_version_spec.rb b/spec/models/ml/model_version_spec.rb index 5daf8b3e5e4..8f17d53787f 100644 --- a/spec/models/ml/model_version_spec.rb +++ b/spec/models/ml/model_version_spec.rb @@ -26,11 +26,15 @@ RSpec.describe Ml::ModelVersion, feature_category: :mlops do build_stubbed(:ml_model_package, project: base_project, version: valid_version, name: model1.name) end + let_it_be(:valid_description) { 'Valid description' } + let(:package) { valid_package } let(:version) { valid_version } + let(:description) { valid_description } subject(:errors) do - mv = described_class.new(version: version, model: model1, package: package, project: model1.project) + mv = described_class.new(version: version, model: model1, package: package, project: model1.project, + description: description) mv.validate mv.errors end @@ -60,6 +64,14 @@ RSpec.describe Ml::ModelVersion, feature_category: :mlops do end end + describe 'description' do + context 'when description is too large' do + let(:description) { 'a' * 501 } + + it { expect(errors).to include(:description) } + end + end + describe 'model' do context 'when project is different' do before do @@ -91,8 +103,9 @@ RSpec.describe Ml::ModelVersion, feature_category: :mlops do let(:version) { existing_model_version.version } let(:package) { nil } + let(:description) { 'Some description' } - subject(:find_or_create) { described_class.find_or_create!(model1, version, package) } + subject(:find_or_create) { described_class.find_or_create!(model1, version, package, description) } context 'if model version exists' do it 'returns the model version', :aggregate_failures do @@ -111,6 +124,7 @@ RSpec.describe Ml::ModelVersion, feature_category: :mlops do expect(model_version.version).to eq(version) expect(model_version.model).to eq(model1) + expect(model_version.description).to eq(description) expect(model_version.package).to eq(package) end end diff --git a/spec/requests/api/graphql/projects/projects_spec.rb b/spec/requests/api/graphql/projects/projects_spec.rb new file mode 100644 index 00000000000..84b8c2285f0 --- /dev/null +++ b/spec/requests/api/graphql/projects/projects_spec.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'getting a collection of projects', feature_category: :source_code_management do + include GraphqlHelpers + + let_it_be(:current_user) { create(:user) } + let_it_be(:group) { create(:group, name: 'public-group') } + let_it_be(:projects) { create_list(:project, 5, :public, group: group) } + let_it_be(:other_project) { create(:project, :public, group: group) } + + let(:filters) { {} } + + let(:query) do + graphql_query_for( + :projects, + filters, + "nodes {#{all_graphql_fields_for('Project', max_depth: 1, excluded: ['productAnalyticsState'])} }" + ) + end + + before_all do + group.add_developer(current_user) + end + + context 'when providing full_paths filter' do + let(:project_full_paths) { projects.map(&:full_path) } + let(:filters) { { full_paths: project_full_paths } } + + let(:single_project_query) do + graphql_query_for( + :projects, + { full_paths: [project_full_paths.first] }, + "nodes {#{all_graphql_fields_for('Project', max_depth: 1, excluded: ['productAnalyticsState'])} }" + ) + end + + it_behaves_like 'a working graphql query that returns data' do + before do + post_graphql(query, current_user: current_user) + end + end + + it 'avoids N+1 queries', :use_sql_query_cache, :clean_gitlab_redis_cache do + post_graphql(single_project_query, current_user: current_user) + + query_count = ActiveRecord::QueryRecorder.new do + post_graphql(single_project_query, current_user: current_user) + end.count + + # There is an N+1 query for max_member_access_for_user_ids + expect do + post_graphql(query, current_user: current_user) + end.not_to exceed_all_query_limit(query_count + 5) + end + + it 'returns the expected projects' do + post_graphql(query, current_user: current_user) + returned_full_paths = graphql_data_at(:projects, :nodes).pluck('fullPath') + + expect(returned_full_paths).to match_array(project_full_paths) + end + + context 'when users provides more than 50 full_paths' do + let(:filters) { { full_paths: Array.new(51) { other_project.full_path } } } + + it 'returns an error' do + post_graphql(query, current_user: current_user) + + expect(graphql_errors).to contain_exactly( + hash_including('message' => _('You cannot provide more than 50 full_paths')) + ) + end + end + end +end diff --git a/spec/services/ml/find_or_create_model_version_service_spec.rb b/spec/services/ml/find_or_create_model_version_service_spec.rb index 1211a9b1165..382d0037dbb 100644 --- a/spec/services/ml/find_or_create_model_version_service_spec.rb +++ b/spec/services/ml/find_or_create_model_version_service_spec.rb @@ -7,12 +7,14 @@ RSpec.describe ::Ml::FindOrCreateModelVersionService, feature_category: :mlops d let_it_be(:another_project) { create(:project) } let(:package) { nil } + let(:description) { nil } let(:params) do { model_name: name, version: version, - package: package + package: package, + description: description } end @@ -34,6 +36,7 @@ RSpec.describe ::Ml::FindOrCreateModelVersionService, feature_category: :mlops d let(:project) { existing_version.project } let(:name) { 'a_new_model' } let(:version) { '2.0.0' } + let(:description) { 'A model version' } let(:package) { create(:ml_model_package, project: project, name: name, version: version) } @@ -43,6 +46,7 @@ RSpec.describe ::Ml::FindOrCreateModelVersionService, feature_category: :mlops d expect(model_version.name).to eq(name) expect(model_version.version).to eq(version) expect(model_version.package).to eq(package) + expect(model_version.description).to eq(description) end end end |