diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-23 18:07:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-23 18:07:50 +0300 |
commit | 676430584d388c5c1a59eec8ab0910ded09c1995 (patch) | |
tree | 58125a10ad92344b802424de7e6c33cfc59881cb /spec | |
parent | 71355c5f36964482ae303c906505dc7138e2c7d7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
14 files changed, 229 insertions, 138 deletions
diff --git a/spec/features/projects/releases/user_views_releases_spec.rb b/spec/features/projects/releases/user_views_releases_spec.rb index fcb1b6a0015..6bc4c66b8ca 100644 --- a/spec/features/projects/releases/user_views_releases_spec.rb +++ b/spec/features/projects/releases/user_views_releases_spec.rb @@ -14,9 +14,14 @@ RSpec.describe 'User views releases', :js do let_it_be(:maintainer) { create(:user) } let_it_be(:guest) { create(:user) } + let_it_be(:internal_link) { create(:release_link, release: release_v1, name: 'An internal link', url: "#{project.web_url}/-/jobs/1/artifacts/download", filepath: nil) } + let_it_be(:internal_link_with_redirect) { create(:release_link, release: release_v1, name: 'An internal link with a redirect', url: "#{project.web_url}/-/jobs/2/artifacts/download", filepath: '/binaries/linux-amd64' ) } + let_it_be(:external_link) { create(:release_link, release: release_v1, name: 'An external link', url: "https://example.com/an/external/link", filepath: nil) } + before do project.add_maintainer(maintainer) project.add_guest(guest) + stub_default_url_options(host: 'localhost') end shared_examples 'releases index page' do @@ -25,6 +30,8 @@ RSpec.describe 'User views releases', :js do sign_in(maintainer) visit project_releases_path(project) + + wait_for_requests end it 'sees the release' do @@ -35,38 +42,18 @@ RSpec.describe 'User views releases', :js do end end - context 'when there is a link as an asset' do - let!(:release_link) { create(:release_link, release: release_v1, url: url ) } - let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" } - let(:direct_asset_link) { Gitlab::Routing.url_helpers.project_release_url(project, release_v1) << "/downloads#{release_link.filepath}" } + it 'renders the correct links', :aggregate_failures do + page.within("##{release_v1.tag} .js-assets-list") do + external_link_indicator_selector = '[data-testid="external-link-indicator"]' - it 'sees the link' do - page.within("##{release_v1.tag} .js-assets-list") do - expect(page).to have_link release_link.name, href: direct_asset_link - expect(page).not_to have_css('[data-testid="external-link-indicator"]') - end - end + expect(page).to have_link internal_link.name, href: internal_link.url + expect(find_link(internal_link.name)).not_to have_css(external_link_indicator_selector) - context 'when there is a link redirect' do - let!(:release_link) { create(:release_link, release: release_v1, name: 'linux-amd64 binaries', filepath: '/binaries/linux-amd64', url: url) } - let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" } + expect(page).to have_link internal_link_with_redirect.name, href: Gitlab::Routing.url_helpers.project_release_url(project, release_v1) << "/downloads#{internal_link_with_redirect.filepath}" + expect(find_link(internal_link_with_redirect.name)).not_to have_css(external_link_indicator_selector) - it 'sees the link', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/329301' do - page.within("##{release_v1.tag} .js-assets-list") do - expect(page).to have_link release_link.name, href: direct_asset_link - expect(page).not_to have_css('[data-testid="external-link-indicator"]') - end - end - end - - context 'when url points to external resource' do - let(:url) { 'http://google.com/download' } - - it 'sees that the link is external resource', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/329302' do - page.within("##{release_v1.tag} .js-assets-list") do - expect(page).to have_css('[data-testid="external-link-indicator"]') - end - end + expect(page).to have_link external_link.name, href: external_link.url + expect(find_link(external_link.name)).to have_css(external_link_indicator_selector) end end diff --git a/spec/frontend/packages/shared/utils_spec.js b/spec/frontend/packages/shared/utils_spec.js index 463e4a4febb..3ea2b78eb14 100644 --- a/spec/frontend/packages/shared/utils_spec.js +++ b/spec/frontend/packages/shared/utils_spec.js @@ -40,6 +40,7 @@ describe('Packages shared utils', () => { ${'pypi'} | ${'PyPI'} ${'rubygems'} | ${'RubyGems'} ${'composer'} | ${'Composer'} + ${'debian'} | ${'Debian'} ${'foo'} | ${null} `(`package type`, ({ packageType, expectedResult }) => { it(`${packageType} should show as ${expectedResult}`, () => { diff --git a/spec/frontend/pipeline_editor/components/editor/ci_editor_header_spec.js b/spec/frontend/pipeline_editor/components/editor/ci_editor_header_spec.js new file mode 100644 index 00000000000..3ee53d4a055 --- /dev/null +++ b/spec/frontend/pipeline_editor/components/editor/ci_editor_header_spec.js @@ -0,0 +1,53 @@ +import { GlButton } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; +import CiEditorHeader from '~/pipeline_editor/components/editor/ci_editor_header.vue'; +import { + pipelineEditorTrackingOptions, + TEMPLATE_REPOSITORY_URL, +} from '~/pipeline_editor/constants'; + +describe('CI Editor Header', () => { + let wrapper; + let trackingSpy = null; + + const createComponent = () => { + wrapper = shallowMount(CiEditorHeader, {}); + }; + + const findLinkBtn = () => wrapper.findComponent(GlButton); + + afterEach(() => { + wrapper.destroy(); + unmockTracking(); + }); + + describe('link button', () => { + beforeEach(() => { + createComponent(); + trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); + }); + + it('finds the browse template button', () => { + expect(findLinkBtn().exists()).toBe(true); + }); + + it('contains the link to the template repo', () => { + expect(findLinkBtn().attributes('href')).toBe(TEMPLATE_REPOSITORY_URL); + }); + + it('has the external-link icon', () => { + expect(findLinkBtn().props('icon')).toBe('external-link'); + }); + + it('tracks the click on the browse button', async () => { + const { label, actions } = pipelineEditorTrackingOptions; + + await findLinkBtn().vm.$emit('click'); + + expect(trackingSpy).toHaveBeenCalledWith(undefined, actions.browse_templates, { + label, + }); + }); + }); +}); diff --git a/spec/frontend/releases/__snapshots__/util_spec.js.snap b/spec/frontend/releases/__snapshots__/util_spec.js.snap index e0a1343c39c..0de2ec5cd89 100644 --- a/spec/frontend/releases/__snapshots__/util_spec.js.snap +++ b/spec/frontend/releases/__snapshots__/util_spec.js.snap @@ -5,6 +5,7 @@ Object { "data": Array [ Object { "_links": Object { + "__typename": "ReleaseLinks", "closedIssuesUrl": "http://localhost/releases-namespace/releases-project/-/issues?release_tag=v1.2&scope=all&state=closed", "closedMergeRequestsUrl": "http://localhost/releases-namespace/releases-project/-/merge_requests?release_tag=v1.2&scope=all&state=closed", "editUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.2/edit", @@ -19,24 +20,29 @@ Object { "links": Array [], "sources": Array [ Object { + "__typename": "ReleaseSource", "format": "zip", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.2/releases-project-v1.2.zip", }, Object { + "__typename": "ReleaseSource", "format": "tar.gz", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.2/releases-project-v1.2.tar.gz", }, Object { + "__typename": "ReleaseSource", "format": "tar.bz2", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.2/releases-project-v1.2.tar.bz2", }, Object { + "__typename": "ReleaseSource", "format": "tar", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.2/releases-project-v1.2.tar", }, ], }, "author": Object { + "__typename": "UserCore", "avatarUrl": "https://www.gravatar.com/avatar/16f8e2050ce10180ca571c2eb19cfce2?s=80&d=identicon", "username": "administrator", "webUrl": "http://localhost/administrator", @@ -57,6 +63,7 @@ Object { }, Object { "_links": Object { + "__typename": "ReleaseLinks", "closedIssuesUrl": "http://localhost/releases-namespace/releases-project/-/issues?release_tag=v1.1&scope=all&state=closed", "closedMergeRequestsUrl": "http://localhost/releases-namespace/releases-project/-/merge_requests?release_tag=v1.1&scope=all&state=closed", "editUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/edit", @@ -70,6 +77,7 @@ Object { "count": 8, "links": Array [ Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/awesome-app-3", "external": true, "id": "gid://gitlab/Releases::Link/13", @@ -78,6 +86,7 @@ Object { "url": "https://example.com/image", }, Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/awesome-app-2", "external": true, "id": "gid://gitlab/Releases::Link/12", @@ -86,6 +95,7 @@ Object { "url": "https://example.com/package", }, Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/awesome-app-1", "external": false, "id": "gid://gitlab/Releases::Link/11", @@ -94,6 +104,7 @@ Object { "url": "http://localhost/releases-namespace/releases-project/runbook", }, Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/linux-amd64", "external": true, "id": "gid://gitlab/Releases::Link/10", @@ -104,24 +115,29 @@ Object { ], "sources": Array [ Object { + "__typename": "ReleaseSource", "format": "zip", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.zip", }, Object { + "__typename": "ReleaseSource", "format": "tar.gz", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.tar.gz", }, Object { + "__typename": "ReleaseSource", "format": "tar.bz2", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.tar.bz2", }, Object { + "__typename": "ReleaseSource", "format": "tar", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.tar", }, ], }, "author": Object { + "__typename": "UserCore", "avatarUrl": "https://www.gravatar.com/avatar/16f8e2050ce10180ca571c2eb19cfce2?s=80&d=identicon", "username": "administrator", "webUrl": "http://localhost/administrator", @@ -134,6 +150,7 @@ Object { "descriptionHtml": "<p data-sourcepos=\\"1:1-1:33\\" dir=\\"auto\\">Best. Release. <strong>Ever.</strong> <gl-emoji title=\\"rocket\\" data-name=\\"rocket\\" data-unicode-version=\\"6.0\\">🚀</gl-emoji></p>", "evidences": Array [ Object { + "__typename": "ReleaseEvidence", "collectedAt": "2018-12-03T00:00:00Z", "filepath": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/evidences/1.json", "sha": "760d6cdfb0879c3ffedec13af470e0f71cf52c6cde4d", @@ -141,6 +158,7 @@ Object { ], "milestones": Array [ Object { + "__typename": "Milestone", "description": "The 12.3 milestone", "id": "gid://gitlab/Milestone/123", "issueStats": Object { @@ -153,6 +171,7 @@ Object { "webUrl": "/releases-namespace/releases-project/-/milestones/1", }, Object { + "__typename": "Milestone", "description": "The 12.4 milestone", "id": "gid://gitlab/Milestone/124", "issueStats": Object { @@ -173,6 +192,7 @@ Object { }, ], "paginationInfo": Object { + "__typename": "PageInfo", "endCursor": "eyJyZWxlYXNlZF9hdCI6IjIwMTgtMTItMTAgMDA6MDA6MDAuMDAwMDAwMDAwIFVUQyIsImlkIjoiMSJ9", "hasNextPage": false, "hasPreviousPage": false, @@ -247,6 +267,7 @@ exports[`releases/util.js convertOneReleaseGraphQLResponse matches snapshot 1`] Object { "data": Object { "_links": Object { + "__typename": "ReleaseLinks", "closedIssuesUrl": "http://localhost/releases-namespace/releases-project/-/issues?release_tag=v1.1&scope=all&state=closed", "closedMergeRequestsUrl": "http://localhost/releases-namespace/releases-project/-/merge_requests?release_tag=v1.1&scope=all&state=closed", "editUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/edit", @@ -260,6 +281,7 @@ Object { "count": 8, "links": Array [ Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/awesome-app-3", "external": true, "id": "gid://gitlab/Releases::Link/13", @@ -268,6 +290,7 @@ Object { "url": "https://example.com/image", }, Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/awesome-app-2", "external": true, "id": "gid://gitlab/Releases::Link/12", @@ -276,6 +299,7 @@ Object { "url": "https://example.com/package", }, Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/awesome-app-1", "external": false, "id": "gid://gitlab/Releases::Link/11", @@ -284,6 +308,7 @@ Object { "url": "http://localhost/releases-namespace/releases-project/runbook", }, Object { + "__typename": "ReleaseAssetLink", "directAssetUrl": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/downloads/binaries/linux-amd64", "external": true, "id": "gid://gitlab/Releases::Link/10", @@ -294,24 +319,29 @@ Object { ], "sources": Array [ Object { + "__typename": "ReleaseSource", "format": "zip", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.zip", }, Object { + "__typename": "ReleaseSource", "format": "tar.gz", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.tar.gz", }, Object { + "__typename": "ReleaseSource", "format": "tar.bz2", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.tar.bz2", }, Object { + "__typename": "ReleaseSource", "format": "tar", "url": "http://localhost/releases-namespace/releases-project/-/archive/v1.1/releases-project-v1.1.tar", }, ], }, "author": Object { + "__typename": "UserCore", "avatarUrl": "https://www.gravatar.com/avatar/16f8e2050ce10180ca571c2eb19cfce2?s=80&d=identicon", "username": "administrator", "webUrl": "http://localhost/administrator", @@ -324,6 +354,7 @@ Object { "descriptionHtml": "<p data-sourcepos=\\"1:1-1:33\\" dir=\\"auto\\">Best. Release. <strong>Ever.</strong> <gl-emoji title=\\"rocket\\" data-name=\\"rocket\\" data-unicode-version=\\"6.0\\">🚀</gl-emoji></p>", "evidences": Array [ Object { + "__typename": "ReleaseEvidence", "collectedAt": "2018-12-03T00:00:00Z", "filepath": "http://localhost/releases-namespace/releases-project/-/releases/v1.1/evidences/1.json", "sha": "760d6cdfb0879c3ffedec13af470e0f71cf52c6cde4d", @@ -331,6 +362,7 @@ Object { ], "milestones": Array [ Object { + "__typename": "Milestone", "description": "The 12.3 milestone", "id": "gid://gitlab/Milestone/123", "issueStats": Object { @@ -343,6 +375,7 @@ Object { "webUrl": "/releases-namespace/releases-project/-/milestones/1", }, Object { + "__typename": "Milestone", "description": "The 12.4 milestone", "id": "gid://gitlab/Milestone/124", "issueStats": Object { diff --git a/spec/frontend/releases/components/app_index_apollo_client_spec.js b/spec/frontend/releases/components/app_index_apollo_client_spec.js index 002d8939058..dcdb56aed59 100644 --- a/spec/frontend/releases/components/app_index_apollo_client_spec.js +++ b/spec/frontend/releases/components/app_index_apollo_client_spec.js @@ -3,6 +3,7 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import allReleasesQuery from 'shared_queries/releases/all_releases.query.graphql'; import createFlash from '~/flash'; import { historyPushState } from '~/lib/utils/common_utils'; import ReleasesIndexApolloClientApp from '~/releases/components/app_index_apollo_client.vue'; @@ -12,7 +13,6 @@ import ReleasesEmptyState from '~/releases/components/releases_empty_state.vue'; import ReleasesPaginationApolloClient from '~/releases/components/releases_pagination_apollo_client.vue'; import ReleasesSortApolloClient from '~/releases/components/releases_sort_apollo_client.vue'; import { PAGE_SIZE, CREATED_ASC, DEFAULT_SORT } from '~/releases/constants'; -import allReleasesQuery from '~/releases/graphql/queries/all_releases.query.graphql'; Vue.use(VueApollo); diff --git a/spec/frontend/security_configuration/components/redesigned_app_spec.js b/spec/frontend/security_configuration/components/redesigned_app_spec.js index 7e27a3e1108..69c79082f5a 100644 --- a/spec/frontend/security_configuration/components/redesigned_app_spec.js +++ b/spec/frontend/security_configuration/components/redesigned_app_spec.js @@ -23,6 +23,7 @@ import { } from '~/vue_shared/security_reports/constants'; const upgradePath = '/upgrade'; +const gitlabCiHistoryPath = 'test/historyPath'; describe('redesigned App component', () => { let wrapper; @@ -52,8 +53,28 @@ describe('redesigned App component', () => { const findTabs = () => wrapper.findAllComponents(GlTab); const findByTestId = (id) => wrapper.findByTestId(id); const findFeatureCards = () => wrapper.findAllComponents(FeatureCard); - const findComplianceViewHistoryLink = () => findByTestId('compliance-view-history-link'); - const findSecurityViewHistoryLink = () => findByTestId('security-view-history-link'); + const findLink = ({ href, text, container = wrapper }) => { + const selector = `a[href="${href}"]`; + const link = container.find(selector); + + if (link.exists() && link.text() === text) { + return link; + } + + return wrapper.find(`${selector} does not exist`); + }; + const findSecurityViewHistoryLink = () => + findLink({ + href: gitlabCiHistoryPath, + text: i18n.configurationHistory, + container: findByTestId('security-testing-tab'), + }); + const findComplianceViewHistoryLink = () => + findLink({ + href: gitlabCiHistoryPath, + text: i18n.configurationHistory, + container: findByTestId('compliance-testing-tab'), + }); const findUpgradeBanner = () => wrapper.findComponent(UpgradeBanner); const securityFeaturesMock = [ @@ -119,6 +140,10 @@ describe('redesigned App component', () => { expect(cards.at(1).props()).toEqual({ feature: complianceFeaturesMock[0] }); }); + it('renders a basic description', () => { + expect(wrapper.text()).toContain(i18n.description); + }); + it('should not show latest pipeline link when latestPipelinePath is not defined', () => { expect(findByTestId('latest-pipeline-info').exists()).toBe(false); }); @@ -193,9 +218,8 @@ describe('redesigned App component', () => { it('should show latest pipeline info on the security tab with correct link when latestPipelinePath is defined', () => { const latestPipelineInfoSecurity = findByTestId('latest-pipeline-info-security'); - expect(latestPipelineInfoSecurity.exists()).toBe(true); expect(latestPipelineInfoSecurity.text()).toMatchInterpolatedText( - i18n.securityTestingDescription, + i18n.latestPipelineDescription, ); expect(latestPipelineInfoSecurity.find('a').attributes('href')).toBe('test/path'); }); @@ -203,9 +227,8 @@ describe('redesigned App component', () => { it('should show latest pipeline info on the compliance tab with correct link when latestPipelinePath is defined', () => { const latestPipelineInfoCompliance = findByTestId('latest-pipeline-info-compliance'); - expect(latestPipelineInfoCompliance.exists()).toBe(true); expect(latestPipelineInfoCompliance.text()).toMatchInterpolatedText( - i18n.securityTestingDescription, + i18n.latestPipelineDescription, ); expect(latestPipelineInfoCompliance.find('a').attributes('href')).toBe('test/path'); }); @@ -217,7 +240,7 @@ describe('redesigned App component', () => { augmentedSecurityFeatures: securityFeaturesMock, augmentedComplianceFeatures: complianceFeaturesMock, gitlabCiPresent: true, - gitlabCiHistoryPath: 'test/historyPath', + gitlabCiHistoryPath, }); }); diff --git a/spec/helpers/releases_helper_spec.rb b/spec/helpers/releases_helper_spec.rb index a18e3d1d7fd..47ea6bbc903 100644 --- a/spec/helpers/releases_helper_spec.rb +++ b/spec/helpers/releases_helper_spec.rb @@ -97,4 +97,42 @@ RSpec.describe ReleasesHelper do end end end + + describe 'startup queries' do + describe 'use_startup_query_for_index_page?' do + it 'allows startup queries for non-paginated requests' do + allow(helper).to receive(:params).and_return({ unrelated_query_param: 'value' }) + + expect(helper.use_startup_query_for_index_page?).to be(true) + end + + it 'disallows startup queries for requests paginated with a "before" cursor' do + allow(helper).to receive(:params).and_return({ unrelated_query_param: 'value', before: 'cursor' }) + + expect(helper.use_startup_query_for_index_page?).to be(false) + end + + it 'disallows startup queries for requests paginated with an "after" cursor' do + allow(helper).to receive(:params).and_return({ unrelated_query_param: 'value', after: 'cursor' }) + + expect(helper.use_startup_query_for_index_page?).to be(false) + end + end + + describe '#index_page_startup_query_variables' do + let_it_be(:project) { build(:project, namespace: create(:group)) } + + before do + helper.instance_variable_set(:@project, project) + end + + it 'returns the correct GraphQL variables for the startup query' do + expect(helper.index_page_startup_query_variables).to eq({ + fullPath: project.full_path, + sort: 'RELEASED_AT_DESC', + first: 1 + }) + end + end + end end diff --git a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb index 0e6d5b6c311..7476fc6c25f 100644 --- a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb @@ -143,51 +143,22 @@ RSpec.describe Gitlab::Ci::Config::Entry::Artifacts do end describe 'excluded artifacts' do - context 'when configuration is valid and the feature is enabled' do - before do - stub_feature_flags(ci_artifacts_exclude: true) - end - - context 'when configuration is valid' do - let(:config) { { untracked: true, exclude: ['some/directory/'] } } - - it 'correctly parses the configuration' do - expect(entry).to be_valid - expect(entry.value).to eq config - end - end + context 'when configuration is valid' do + let(:config) { { untracked: true, exclude: ['some/directory/'] } } - context 'when configuration is not valid' do - let(:config) { { untracked: true, exclude: 1234 } } - - it 'returns an error' do - expect(entry).not_to be_valid - expect(entry.errors) - .to include 'artifacts exclude should be an array of strings' - end + it 'correctly parses the configuration' do + expect(entry).to be_valid + expect(entry.value).to eq config end end - context 'when artifacts/exclude feature is disabled' do - before do - stub_feature_flags(ci_artifacts_exclude: false) - end - - context 'when configuration has been provided' do - let(:config) { { untracked: true, exclude: ['some/directory/'] } } - - it 'returns an error' do - expect(entry).not_to be_valid - expect(entry.errors).to include 'artifacts exclude feature is disabled' - end - end + context 'when configuration is not valid' do + let(:config) { { untracked: true, exclude: 1234 } } - context 'when configuration is not present' do - let(:config) { { untracked: true } } - - it 'is a valid configuration' do - expect(entry).to be_valid - end + it 'returns an error' do + expect(entry).not_to be_valid + expect(entry.errors) + .to include 'artifacts exclude should be an array of strings' end end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index e8e44f884cf..dccf8c0695d 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1648,8 +1648,6 @@ module Gitlab end it 'populates a build options with complete artifacts configuration' do - stub_feature_flags(ci_artifacts_exclude: true) - config = <<~YAML test: script: echo "Hello World" diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index b004ea6f767..6290006b01b 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -4493,26 +4493,12 @@ RSpec.describe Ci::Build do it { is_expected.to include(:upload_multiple_artifacts) } end - context 'when artifacts exclude is defined and the is feature enabled' do + context 'when artifacts exclude is defined' do let(:options) do { artifacts: { exclude: %w[something] } } end - context 'when a feature flag is enabled' do - before do - stub_feature_flags(ci_artifacts_exclude: true) - end - - it { is_expected.to include(:artifacts_exclude) } - end - - context 'when a feature flag is disabled' do - before do - stub_feature_flags(ci_artifacts_exclude: false) - end - - it { is_expected.not_to include(:artifacts_exclude) } - end + it { is_expected.to include(:artifacts_exclude) } end end diff --git a/spec/presenters/ci/build_runner_presenter_spec.rb b/spec/presenters/ci/build_runner_presenter_spec.rb index 9cb00781e99..8d20bb590e9 100644 --- a/spec/presenters/ci/build_runner_presenter_spec.rb +++ b/spec/presenters/ci/build_runner_presenter_spec.rb @@ -44,29 +44,13 @@ RSpec.describe Ci::BuildRunnerPresenter do create(:ci_build, options: { artifacts: { paths: %w[abc], exclude: %w[cde] } }) end - context 'when the feature is enabled' do - before do - stub_feature_flags(ci_artifacts_exclude: true) - end - - it 'includes the list of excluded paths' do - expect(presenter.artifacts.first).to include( - artifact_type: :archive, - artifact_format: :zip, - paths: %w[abc], - exclude: %w[cde] - ) - end - end - - context 'when the feature is disabled' do - before do - stub_feature_flags(ci_artifacts_exclude: false) - end - - it 'does not include the list of excluded paths' do - expect(presenter.artifacts.first).not_to have_key(:exclude) - end + it 'includes the list of excluded paths' do + expect(presenter.artifacts.first).to include( + artifact_type: :archive, + artifact_format: :zip, + paths: %w[abc], + exclude: %w[cde] + ) end end diff --git a/spec/requests/api/ci/runner/jobs_request_post_spec.rb b/spec/requests/api/ci/runner/jobs_request_post_spec.rb index 1e0b2e76da1..00c3a0a31af 100644 --- a/spec/requests/api/ci/runner/jobs_request_post_spec.rb +++ b/spec/requests/api/ci/runner/jobs_request_post_spec.rb @@ -803,29 +803,16 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do end context 'when a runner supports this feature' do - it 'exposes excluded paths when the feature is enabled' do - stub_feature_flags(ci_artifacts_exclude: true) - + it 'exposes excluded paths' do request_job info: { features: { artifacts_exclude: true } } expect(response).to have_gitlab_http_status(:created) expect(json_response.dig('artifacts').first).to include('exclude' => ['cde']) end - - it 'does not expose excluded paths when the feature is disabled' do - stub_feature_flags(ci_artifacts_exclude: false) - - request_job info: { features: { artifacts_exclude: true } } - - expect(response).to have_gitlab_http_status(:created) - expect(json_response.dig('artifacts').first).not_to have_key('exclude') - end end context 'when a runner does not support this feature' do it 'does not expose the build at all' do - stub_feature_flags(ci_artifacts_exclude: true) - request_job expect(response).to have_gitlab_http_status(:no_content) diff --git a/spec/services/merge_requests/push_options_handler_service_spec.rb b/spec/services/merge_requests/push_options_handler_service_spec.rb index c09435a70e2..5f76f6f5c44 100644 --- a/spec/services/merge_requests/push_options_handler_service_spec.rb +++ b/spec/services/merge_requests/push_options_handler_service_spec.rb @@ -5,12 +5,16 @@ require 'spec_helper' RSpec.describe MergeRequests::PushOptionsHandlerService do include ProjectForksHelper - let_it_be(:project) { create(:project, :public, :repository) } + let_it_be(:parent_group) { create(:group, :public) } + let_it_be(:child_group) { create(:group, :public, parent: parent_group) } + let_it_be(:project) { create(:project, :public, :repository, group: child_group) } let_it_be(:user1) { create(:user, developer_projects: [project]) } let_it_be(:user2) { create(:user, developer_projects: [project]) } let_it_be(:user3) { create(:user, developer_projects: [project]) } let_it_be(:forked_project) { fork_project(project, user1, repository: true) } - let_it_be(:milestone) { create(:milestone, project: project, title: '1.0') } + let_it_be(:parent_group_milestone) { create(:milestone, group: parent_group, title: 'ParentGroupMilestone1.0') } + let_it_be(:child_group_milestone) { create(:milestone, group: child_group, title: 'ChildGroupMilestone1.0') } + let_it_be(:project_milestone) { create(:milestone, project: project, title: 'ProjectMilestone1.0') } let(:service) { described_class.new(project: project, current_user: user1, changes: changes, push_options: push_options) } let(:source_branch) { 'fix' } @@ -527,8 +531,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do describe '`milestone` push option' do context 'with a valid milestone' do - let(:expected_milestone) { milestone.title } - let(:push_options) { { milestone: milestone.title } } + let(:expected_milestone) { project_milestone.title } + let(:push_options) { { milestone: project_milestone.title } } context 'with a new branch' do let(:changes) { new_branch_changes } @@ -542,7 +546,7 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do end context 'when coupled with the `create` push option' do - let(:push_options) { { create: true, milestone: milestone.title } } + let(:push_options) { { create: true, milestone: project_milestone.title } } it_behaves_like 'a service that can create a merge request' it_behaves_like 'a service that can set the milestone of a merge request' @@ -561,7 +565,7 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do end context 'when coupled with the `create` push option' do - let(:push_options) { { create: true, milestone: milestone.title } } + let(:push_options) { { create: true, milestone: project_milestone.title } } it_behaves_like 'a service that can create a merge request' it_behaves_like 'a service that can set the milestone of a merge request' @@ -587,6 +591,26 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do it_behaves_like 'a service that can set the milestone of a merge request' end + + context 'with an ancestor milestone' do + let(:changes) { existing_branch_changes } + + context 'with immediate parent milestone' do + let(:push_options) { { create: true, milestone: child_group_milestone.title } } + let(:expected_milestone) { child_group_milestone.title } + + it_behaves_like 'a service that can create a merge request' + it_behaves_like 'a service that can set the milestone of a merge request' + end + + context 'with multi-level ancestor milestone' do + let(:push_options) { { create: true, milestone: parent_group_milestone.title } } + let(:expected_milestone) { parent_group_milestone.title } + + it_behaves_like 'a service that can create a merge request' + it_behaves_like 'a service that can set the milestone of a merge request' + end + end end shared_examples 'with an existing branch that has a merge request open in foss' do diff --git a/spec/workers/concerns/waitable_worker_spec.rb b/spec/workers/concerns/waitable_worker_spec.rb index 5d08d38380a..824ae8fcf83 100644 --- a/spec/workers/concerns/waitable_worker_spec.rb +++ b/spec/workers/concerns/waitable_worker_spec.rb @@ -38,6 +38,12 @@ RSpec.describe WaitableWorker do it 'inlines workloads <= 3 jobs' do args_list = [[1], [2], [3]] expect(worker).to receive(:bulk_perform_inline).with(args_list).and_call_original + expect(Gitlab::AppJsonLogger).to( + receive(:info).with(a_hash_including('message' => 'running inline', + 'class' => 'Gitlab::Foo::Bar::DummyWorker', + 'job_status' => 'running', + 'queue' => 'foo_bar_dummy')) + .exactly(3).times) worker.bulk_perform_and_wait(args_list) |