Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-05-12 21:09:08 +00:00
parent aed0a60015
commit f64dc893b8
38 changed files with 369 additions and 98 deletions

View file

@ -9,6 +9,7 @@ import { getBulkImportsHistory } from '~/rest_api';
import ImportStatus from '~/import_entities/components/import_status.vue';
import PaginationBar from '~/vue_shared/components/pagination_bar/pagination_bar.vue';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import { DEFAULT_ERROR } from '../utils/error_messages';
@ -16,6 +17,8 @@ const DEFAULT_PER_PAGE = 20;
const DEFAULT_TH_CLASSES =
'gl-bg-transparent! gl-border-b-solid! gl-border-b-gray-200! gl-border-b-1! gl-p-5!';
const HISTORY_PAGINATION_SIZE_PERSIST_KEY = 'gl-bulk-imports-history-per-page';
const tableCell = (config) => ({
thClass: `${DEFAULT_TH_CLASSES}`,
tdClass: (value, key, item) => {
@ -37,6 +40,7 @@ export default {
PaginationBar,
ImportStatus,
TimeAgo,
LocalStorageSync,
},
data() {
@ -85,10 +89,13 @@ export default {
this.loadHistoryItems();
},
deep: true,
immediate: true,
},
},
mounted() {
this.loadHistoryItems();
},
methods: {
async loadHistoryItems() {
try {
@ -116,6 +123,7 @@ export default {
},
gitlabLogo: window.gon.gitlab_logo,
historyPaginationSizePersistKey: HISTORY_PAGINATION_SIZE_PERSIST_KEY,
};
</script>
@ -171,5 +179,9 @@ export default {
@set-page-size="paginationConfig.perPage = $event"
/>
</template>
<local-storage-sync
v-model="paginationConfig.perPage"
:storage-key="$options.historyPaginationSizePersistKey"
/>
</div>
</template>

View file

@ -139,7 +139,7 @@ export default {
<div
class="gl-p-2 flex-shrink-1 gl-display-flex gl-flex-direction-column align-items-center gl-w-70p"
>
<user-avatar-image :img-src="user.avatarUrl" :size="64" css-classes="gl-mr-3!" />
<user-avatar-image :img-src="user.avatarUrl" :size="64" css-classes="gl-m-0!" />
<div v-if="shouldRenderToggleFollowButton" class="gl-mt-3">
<gl-button
:variant="toggleFollowButtonVariant"
@ -151,7 +151,7 @@ export default {
>
</div>
</div>
<div class="gl-w-full gl-min-w-0">
<div class="gl-w-full gl-min-w-0 gl-word-break-word">
<template v-if="userIsLoading">
<gl-skeleton-loader
:lines="$options.maxSkeletonLines"
@ -174,7 +174,7 @@ export default {
<div class="gl-text-gray-500">
<div v-if="user.bio" class="gl-display-flex gl-mb-2">
<gl-icon name="profile" class="gl-flex-shrink-0" />
<span ref="bio" class="gl-ml-2 gl-overflow-hidden">{{ user.bio }}</span>
<span ref="bio" class="gl-ml-2">{{ user.bio }}</span>
</div>
<div v-if="user.workInformation" class="gl-display-flex gl-mb-2">
<gl-icon name="work" class="gl-flex-shrink-0" />

View file

@ -9,7 +9,7 @@ module Types
value 'remote', description: 'Remote include.', value: :remote
value 'local', description: 'Local include.', value: :local
value 'project', description: 'Project include.', value: :project
value 'file', description: 'Project file include.', value: :file
value 'template', description: 'Template include.', value: :template
end
end

View file

@ -2,7 +2,7 @@
module TrackingHelper
def tracking_attrs(label, action, property)
return {} unless tracking_enabled?
return {} unless ::Gitlab::Tracking.enabled?
{
data: {
@ -16,11 +16,4 @@ module TrackingHelper
def tracking_attrs_data(label, action, property)
tracking_attrs(label, action, property).fetch(:data, {})
end
private
def tracking_enabled?
Rails.env.production? &&
::Gitlab::Tracking.enabled?
end
end

View file

@ -53,7 +53,6 @@ class Project < ApplicationRecord
ignore_columns :mirror_last_update_at, :mirror_last_successful_update_at, remove_after: '2021-09-22', remove_with: '14.4'
ignore_columns :pull_mirror_branch_prefix, remove_after: '2021-09-22', remove_with: '14.4'
ignore_columns :build_coverage_regex, remove_after: '2022-07-22', remove_with: '15.0'
STATISTICS_ATTRIBUTE = 'repositories_count'
UNKNOWN_IMPORT_URL = 'http://unknown.git'

View file

@ -203,6 +203,12 @@ module MergeRequests
target_branch.blank? || target_project.commit(target_branch)
end
def set_draft_title_if_needed
return unless compare_commits.empty? || Gitlab::Utils.to_boolean(params[:draft])
merge_request.title = wip_title
end
# When your branch name starts with an iid followed by a dash this pattern will be
# interpreted as the user wants to close that issue on this project.
#
@ -220,7 +226,7 @@ module MergeRequests
assign_title_and_description_from_commits
merge_request.title ||= title_from_issue if target_project.issues_enabled? || target_project.external_issue_tracker
merge_request.title ||= source_branch.titleize.humanize
merge_request.title = wip_title if compare_commits.empty?
set_draft_title_if_needed
append_closes_description
end

View file

@ -126,6 +126,7 @@ module MergeRequests
params = {
title: push_options[:title],
description: push_options[:description],
draft: push_options[:draft],
target_branch: push_options[:target],
force_remove_source_branch: push_options[:remove_source_branch],
label: push_options[:label],

View file

@ -11,6 +11,10 @@ module MergeRequests
end
def execute(merge_request)
if Gitlab::Utils.to_boolean(params[:draft])
merge_request.title = merge_request.draft_title
end
update_merge_request_with_specialized_service(merge_request) || general_fallback(merge_request)
end

View file

@ -14,7 +14,7 @@
%button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }
= expanded ? _('Collapse') : _('Expand')
%p
= _("Customize your pipeline configuration and coverage report.")
= _("Customize your pipeline configuration.")
.settings-content
= render 'form'

View file

@ -1,28 +0,0 @@
# This is a template for a feature deprecation
# A deprecation typically occurs when a feature or capability is planned to be removed in a future release.
# Deprecations should be announced at least two releases prior to removal. Any breaking changes should only be done in major releases.
#
# Below is an example of what a single entry should look like, it's required attributes,
# and what types we expect those attribute values to be.
#
# For more information please refer to the handbook documentation here:
# https://about.gitlab.com/handbook/marketing/blog/release-posts/#deprecations
#
# Please delete this line and above before submitting your merge request.
- name: "Changes to the `CI_JOB_JWT`" # The name of the feature to be deprecated
announcement_milestone: "14.8" # The milestone when this feature was first announced as deprecated.
announcement_date: "2022-02-22" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
removal_milestone: "15.0" # The milestone when this feature is planned to be removed
removal_date: "2022-05-22" # The date of the milestone release when this feature is planned to be removed. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
breaking_change: true # If this deprecation is a breaking change, set this value to true
reporter: dhershkovitch # GitLab username of the person reporting the deprecation
body: | # Do not modify this line, instead modify the lines below.
The `CI_JOB_JWT` will be updated to support a wider variety of cloud providers. It will be changed to match [`CI_JOB_JWT_V2`](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html), but this change may not be backwards compatible for all users, including Hashicorp Vault users. To maintain the current behavior, users can switch to using `CI_JOB_JWT_V1`, or update their configuration in GitLab 15.0 to use the improved `CI_JOB_JWT`.
# The following items are not published on the docs page, but may be used in the future.
stage: verify
tiers: # (optional - may be required in the future) An array of tiers that the feature is available in currently. e.g., [Free, Silver, Gold, Core, Premium, Ultimate]
issue_url: # (optional) This is a link to the deprecation issue in GitLab
documentation_url: # (optional) This is a link to the current documentation page
image_url: # (optional) This is a link to a thumbnail image depicting the feature
video_url: # (optional) Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg

View file

@ -0,0 +1,28 @@
# frozen_string_literal: true
class FixAutomaticIterationsCadencesStartDate < Gitlab::Database::Migration[2.0]
restrict_gitlab_migration gitlab_schema: :gitlab_main
def up
execute(<<~SQL)
UPDATE iterations_cadences
SET start_date=COALESCE(
(
SELECT start_date
FROM sprints
WHERE iterations_cadences.id=sprints.iterations_cadence_id
ORDER BY sprints.start_date ASC
LIMIT 1
),
start_date
)
WHERE iterations_cadences.automatic=true;
SQL
end
def down
# no-op
# The migration updates the records for the feature used behind a non-default feature flag.
# The correct data can be computed with the records from 'sprints' table.
end
end

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
class RemoveNamespacesIdParentIdInversePartialIndex < Gitlab::Database::Migration[2.0]
disable_ddl_transaction!
NAME = 'index_namespaces_id_parent_id_is_not_null'
def up
remove_concurrent_index :namespaces, :id, name: NAME
end
def down
add_concurrent_index :namespaces, :id, where: 'parent_id IS NOT NULL', name: NAME
end
end

View file

@ -0,0 +1 @@
50c34d341ad1d989b865e2d9f6ac11d19e18c756436b8385518d1210bc2e6fe1

View file

@ -0,0 +1 @@
e1b5a06c0a72e361d308f599d446125aaf5882a986423cc0b29c5faa9bc3954b

View file

@ -28385,8 +28385,6 @@ CREATE UNIQUE INDEX index_namespace_root_storage_statistics_on_namespace_id ON n
CREATE UNIQUE INDEX index_namespace_statistics_on_namespace_id ON namespace_statistics USING btree (namespace_id);
CREATE INDEX index_namespaces_id_parent_id_is_not_null ON namespaces USING btree (id) WHERE (parent_id IS NOT NULL);
CREATE UNIQUE INDEX index_namespaces_name_parent_id_type ON namespaces USING btree (name, parent_id, type);
CREATE INDEX index_namespaces_on_created_at ON namespaces USING btree (created_at);

View file

@ -17961,8 +17961,8 @@ Include type.
| Value | Description |
| ----- | ----------- |
| <a id="ciconfigincludetypefile"></a>`file` | Project file include. |
| <a id="ciconfigincludetypelocal"></a>`local` | Local include. |
| <a id="ciconfigincludetypeproject"></a>`project` | Project include. |
| <a id="ciconfigincludetyperemote"></a>`remote` | Remote include. |
| <a id="ciconfigincludetypetemplate"></a>`template` | Template include. |

View file

@ -49,6 +49,7 @@ GET /projects
| Attribute | Type | Required | Description |
|--------------------------------------------|----------|------------------------|-------------|
| `archived` | boolean | **{dotted-circle}** No | Limit by archived status. |
| `build_coverage_regex` | string | **{dotted-circle}** No | Test coverage parsing. (`deprecated`, it is [scheduled to be removed](https://gitlab.com/gitlab-org/gitlab/-/issues/357401)) |
| `id_after` | integer | **{dotted-circle}** No | Limit results to projects with IDs greater than the specified ID. |
| `id_before` | integer | **{dotted-circle}** No | Limit results to projects with IDs less than the specified ID. |
| `imported` | boolean | **{dotted-circle}** No | Limit results to projects which were imported from external systems by current user. |
@ -2757,6 +2758,7 @@ Example response:
"public_jobs": true,
"build_timeout": 3600,
"auto_cancel_pending_pipelines": "enabled",
"build_coverage_regex": null, // deprecated, it is scheduled to be removed https://gitlab.com/gitlab-org/gitlab/-/issues/357401
"ci_config_path": null,
"shared_with_groups": [],
"only_allow_merge_if_pipeline_succeeds": false,

View file

@ -97,10 +97,12 @@ If click events stop propagating, you must implement listeners and [Vue componen
#### Helper methods
You can use the following Ruby helper:
You can use the following Ruby helpers:
```ruby
tracking_attrs(label, action, property) # { data: { track_label... } }
tracking_attrs_data(label, action, property) # { track_label... }
```
You can also use it on HAML templates:
@ -108,8 +110,8 @@ You can also use it on HAML templates:
```haml
%button{ **tracking_attrs('main_navigation', 'click_button', 'navigation') }
// When adding additional data
// %button{ data: { platform: "...", **tracking_attrs('main_navigation', 'click_button', 'navigation') } }
// When merging with additional data
// %button{ data: { platform: "...", **tracking_attrs_data('main_navigation', 'click_button', 'navigation') } }
```
If you use the GitLab helper method [`nav_link`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/helpers/tab_helper.rb#L76), you must wrap `html_options` under the `html_options` keyword argument. If you

View file

@ -332,21 +332,6 @@ Any API calls attempting to change the rate limits for `user_email_lookup_limit`
## 14.8
<div class="deprecation removal-150 breaking-change">
### Changes to the `CI_JOB_JWT`
WARNING:
This feature will be changed or removed in 15.0
as a [breaking change](https://docs.gitlab.com/ee/development/contributing/#breaking-changes).
Before updating GitLab, review the details carefully to determine if you need to make any
changes to your code, settings, or workflow.
The `CI_JOB_JWT` will be updated to support a wider variety of cloud providers. It will be changed to match [`CI_JOB_JWT_V2`](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html), but this change may not be backwards compatible for all users, including Hashicorp Vault users. To maintain the current behavior, users can switch to using `CI_JOB_JWT_V1`, or update their configuration in GitLab 15.0 to use the improved `CI_JOB_JWT`.
**Planned removal milestone: <span class="removal-milestone">15.0</span> (2022-05-22)**
</div>
<div class="deprecation removal-149">
### Configurable Gitaly `per_repository` election strategy

View file

@ -1189,7 +1189,7 @@ We recommend committing the lock files, which prevents this warning.
If you have manually set `DS_MAJOR_VERSION` or `DS_ANALYZER_IMAGE` for specific reasons,
and now must update your configuration to again get the latest patched versions of our
analyzers, edit your `gitlab-ci.yml` file and either:
analyzers, edit your `.gitlab-ci.yml` file and either:
- Set your `DS_MAJOR_VERSION` to match the latest version as seen in
[our current Dependency Scanning template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml#L18).

View file

@ -472,7 +472,7 @@ Additional details about the differences between the two solutions are outlined
| ------ | ------ | ------ |
| **Flexibility** | Supports anything that can be done in a CI file. | Limited to only the items for which GitLab has explicitly added support. DAST, SAST, Secret Detection, and Container Scanning scans are supported. |
| **Usability** | Requires knowledge of CI YAML. | Follows a `rules` and `actions`-based YAML structure. |
| **Inclusion in CI pipeline** | The compliance pipeline is executed instead of the project's `gitlab-ci.yml` file. To include the project's `gitlab-ci.yml` file, use an `include` statement. Defined variables aren't allowed to be overwritten by the included project's YAML file. | Forced inclusion of a new job into the CI pipeline. DAST jobs that must be customized on a per-project basis can have project-level Site Profiles and Scan Profiles defined. To ensure separation of duties, these profiles are immutable when referenced in a scan execution policy. All jobs can be customized as part of the security policy itself with the same variables that are normally available to the CI job. |
| **Inclusion in CI pipeline** | The compliance pipeline is executed instead of the project's `.gitlab-ci.yml` file. To include the project's `.gitlab-ci.yml` file, use an `include` statement. Defined variables aren't allowed to be overwritten by the included project's YAML file. | Forced inclusion of a new job into the CI pipeline. DAST jobs that must be customized on a per-project basis can have project-level Site Profiles and Scan Profiles defined. To ensure separation of duties, these profiles are immutable when referenced in a scan execution policy. All jobs can be customized as part of the security policy itself with the same variables that are normally available to the CI job. |
| **Schedulable** | Can be scheduled through a scheduled pipeline on the group. | Can be scheduled natively through the policy configuration itself. |
| **Separation of Duties** | Only group owners can create compliance framework labels. Only project owners can apply compliance framework labels to projects. The ability to make or approve changes to the compliance pipeline definition is limited to individuals who are explicitly given access to the project that contains the compliance pipeline. | Only project owners can define a linked security policy project. The ability to make or approve changes to security policies is limited to individuals who are explicitly given access to the security policy project. |
| **Ability to apply one standard to multiple projects** | The same compliance framework label can be applied to multiple projects inside a group. | The same security policy project can be used for multiple projects across GitLab with no requirement of being located in the same group. |

View file

@ -249,7 +249,7 @@ SPDY protocol.
Tools like `kubectl`, Helm, `kpt`, and `kustomize` cache information about
the cluster in `~/.kube/cache`. If this directory is not writable, the tool fetches information on each invocation,
making interactions slower and creating unnecessary load on the cluster. For the best experience, in the
image you use in your .`gitlab-ci.yml` file, ensure this directory is writable.
image you use in your `.gitlab-ci.yml` file, ensure this directory is writable.
### Enable TLS

View file

@ -63,6 +63,7 @@ time as pushing changes:
| `merge_request.remove_source_branch` | Set the merge request to remove the source branch when it's merged. | [12.2](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/64320) |
| `merge_request.title="<title>"` | Set the title of the merge request. Ex: `git push -o merge_request.title="The title I want"`. | [12.2](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/64320) |
| `merge_request.description="<description>"` | Set the description of the merge request. Ex: `git push -o merge_request.description="The description I want"`. | [12.2](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/64320) |
| `merge_request.draft` | Mark the merge request as a draft. Ex: `git push -o merge_request.draft`. | [15.0](https://gitlab.com/gitlab-org/gitlab/-/issues/296673) |
| `merge_request.milestone="<milestone>"` | Set the milestone of the merge request. Ex: `git push -o merge_request.milestone="3.0"`. | [14.1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/63960) |
| `merge_request.label="<label>"` | Add labels to the merge request. If the label does not exist, it is created. For example, for two labels: `git push -o merge_request.label="label1" -o merge_request.label="label2"`. | [12.3](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/31831) |
| `merge_request.unlabel="<label>"` | Remove labels from the merge request. For example, for two labels: `git push -o merge_request.unlabel="label1" -o merge_request.unlabel="label2"`. | [12.3](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/31831) |

View file

@ -88,11 +88,11 @@ read-only view to discourage this behavior.
Compliance framework pipelines allow group owners to define
a compliance pipeline in a separate repository that gets
executed in place of the local project's `gitlab-ci.yml` file. As part of this pipeline, an
`include` statement can reference the local project's `gitlab-ci.yml` file. This way, the compliance
executed in place of the local project's `.gitlab-ci.yml` file. As part of this pipeline, an
`include` statement can reference the local project's `.gitlab-ci.yml` file. This way, the compliance
pipeline jobs can run alongside the project-specific jobs any time the pipeline runs.
Jobs and variables defined in the compliance
pipeline can't be changed by variables in the local project's `gitlab-ci.yml` file.
pipeline can't be changed by variables in the local project's `.gitlab-ci.yml` file.
When you set up the compliance framework, use the **Compliance pipeline configuration** box to link
the compliance framework to specific CI/CD configuration. Use the

View file

@ -109,6 +109,7 @@ module API
end
expose :build_timeout
expose :auto_cancel_pending_pipelines
expose :build_coverage_regex
expose :ci_config_path, if: -> (project, options) { Ability.allowed?(options[:current_user], :download_code, project) }
expose :shared_with_groups do |project, options|
user = options[:current_user]

View file

@ -639,6 +639,7 @@ included_attributes:
- :auto_cancel_pending_pipelines
- :autoclose_referenced_issues
- :build_allow_git_fetch
- :build_coverage_regex
- :build_timeout
- :delete_error
- :description

View file

@ -8,6 +8,7 @@ module Gitlab
:assign,
:create,
:description,
:draft,
:label,
:merge_when_pipeline_succeeds,
:milestone,

View file

@ -10879,9 +10879,6 @@ msgstr ""
msgid "Customize name"
msgstr ""
msgid "Customize your pipeline configuration and coverage report."
msgstr ""
msgid "Customize your pipeline configuration."
msgstr ""
@ -11201,6 +11198,9 @@ msgstr ""
msgid "DastProfiles|Are you sure you want to delete this profile?"
msgstr ""
msgid "DastProfiles|Attacks the target to find potential vulnerabilities. Active scans are potentially harmful to the site being scanned."
msgstr ""
msgid "DastProfiles|Authentication"
msgstr ""
@ -11312,6 +11312,9 @@ msgstr ""
msgid "DastProfiles|Minimum = 1 second, Maximum = 3600 seconds"
msgstr ""
msgid "DastProfiles|Monitors all HTTP requests sent to the target to find potential vulnerabilities."
msgstr ""
msgid "DastProfiles|New scanner profile"
msgstr ""

View file

@ -21,8 +21,6 @@ rules:
- 'expect*'
- 'assert*'
- 'testAction'
jest/no-test-callback:
- off
"@gitlab/no-global-event-off":
- off
import/no-unresolved:

View file

@ -3,6 +3,7 @@ import { mount, shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import PaginationBar from '~/vue_shared/components/pagination_bar/pagination_bar.vue';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import BulkImportsHistoryApp from '~/pages/import/bulk_imports/history/components/bulk_imports_history_app.vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
@ -60,6 +61,8 @@ describe('BulkImportsHistoryApp', () => {
wrapper = mountFn(BulkImportsHistoryApp);
}
const findLocalStorageSync = () => wrapper.findComponent(LocalStorageSync);
const originalApiVersion = gon.api_version;
beforeAll(() => {
gon.api_version = 'v4';
@ -137,6 +140,20 @@ describe('BulkImportsHistoryApp', () => {
);
});
it('sets up the local storage sync correctly', async () => {
const NEW_PAGE_SIZE = 4;
mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
createComponent();
await axios.waitForAll();
mock.resetHistory();
wrapper.findComponent(PaginationBar).vm.$emit('set-page-size', NEW_PAGE_SIZE);
await axios.waitForAll();
expect(findLocalStorageSync().props('value')).toBe(NEW_PAGE_SIZE);
});
it('renders correct url for destination group when relative_url is empty', async () => {
mock.onGet(API_URL).reply(200, DUMMY_RESPONSE, DEFAULT_HEADERS);
createComponent({ shallow: false });

View file

@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['CiConfigIncludeType'] do
it { expect(described_class.graphql_name).to eq('CiConfigIncludeType') }
it 'exposes all the existing include types' do
expect(described_class.values.keys).to match_array(%w[remote local project template])
expect(described_class.values.keys).to match_array(%w[remote local file template])
end
end

View file

@ -7,7 +7,7 @@ RSpec.describe SidebarsHelper do
subject { helper.sidebar_tracking_attributes_by_object(object) }
before do
allow(helper).to receive(:tracking_enabled?).and_return(true)
stub_application_setting(snowplow_enabled: true)
end
context 'when object is a project' do

View file

@ -7,29 +7,24 @@ RSpec.describe TrackingHelper do
using RSpec::Parameterized::TableSyntax
let(:input) { %w(a b c) }
let(:results) do
{
no_data: {},
with_data: { data: { track_label: 'a', track_action: 'b', track_property: 'c' } }
}
let(:result) { { data: { track_label: 'a', track_action: 'b', track_property: 'c' } } }
before do
stub_application_setting(snowplow_enabled: true)
end
where(:snowplow_enabled, :environment, :result) do
true | 'production' | :with_data
false | 'production' | :no_data
true | 'development' | :no_data
false | 'development' | :no_data
true | 'test' | :no_data
false | 'test' | :no_data
it 'returns no data if snowplow is disabled' do
stub_application_setting(snowplow_enabled: false)
expect(helper.tracking_attrs(*input)).to eq({})
end
with_them do
it 'returns a hash' do
stub_application_setting(snowplow_enabled: snowplow_enabled)
allow(Rails).to receive(:env).and_return(environment.inquiry)
it 'returns data hash' do
expect(helper.tracking_attrs(*input)).to eq(result)
end
expect(helper.tracking_attrs(*input)).to eq(results[result])
end
it 'can return data directly' do
expect(helper.tracking_attrs_data(*input)).to eq(result[:data])
end
end
end

View file

@ -521,6 +521,7 @@ Project:
- star_count
- ci_id
- shared_runners_enabled
- build_coverage_regex
- build_allow_git_fetchs
- build_timeout
- pending_delete

View file

@ -0,0 +1,63 @@
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe FixAutomaticIterationsCadencesStartDate do
let(:migration) { described_class.new }
let(:namespaces) { table(:namespaces) }
let(:sprints) { table(:sprints) }
let(:iterations_cadences) { table(:iterations_cadences) }
let!(:group1) { namespaces.create!(name: 'abc', path: 'abc') }
let!(:group2) { namespaces.create!(name: 'def', path: 'def') }
let(:jan2022) { Date.new(2022, 1, 1) }
let(:feb2022) { Date.new(2022, 2, 1) }
let(:may2022) { Date.new(2022, 5, 1) }
let(:dec2022) { Date.new(2022, 12, 1) }
let!(:cadence1) { iterations_cadences.create!(start_date: jan2022, title: "ic 1", group_id: group1.id) }
let!(:cadence2) { iterations_cadences.create!(start_date: may2022, group_id: group1.id, title: "ic 2") }
let!(:cadence3) do
iterations_cadences.create!(start_date: jan2022, automatic: false, group_id: group2.id, title: "ic 3 (invalid)")
end
let!(:cadence4) { iterations_cadences.create!(start_date: jan2022, group_id: group2.id, title: "ic 4 (invalid)") }
before do
sprints.create!(id: 2, start_date: jan2022, due_date: jan2022 + 1.week, iterations_cadence_id: cadence1.id,
group_id: group1.id, iid: 1)
sprints.create!(id: 1, start_date: dec2022, due_date: dec2022 + 1.week, iterations_cadence_id: cadence1.id,
group_id: group1.id, iid: 2)
sprints.create!(id: 4, start_date: feb2022, due_date: feb2022 + 1.week, iterations_cadence_id: cadence3.id,
group_id: group2.id, iid: 1)
sprints.create!(id: 3, start_date: may2022, due_date: may2022 + 1.week, iterations_cadence_id: cadence3.id,
group_id: group2.id, iid: 2)
sprints.create!(id: 5, start_date: may2022, due_date: may2022 + 1.week, iterations_cadence_id: cadence4.id,
group_id: group2.id, iid: 4)
sprints.create!(id: 6, start_date: feb2022, due_date: feb2022 + 1.week, iterations_cadence_id: cadence4.id,
group_id: group2.id, iid: 3)
end
describe '#up' do
it "updates automatic iterations_cadence records to use start dates of their earliest sprint records" do
migrate!
# This cadence has a valid start date. Its start date should be left as it is
expect(cadence1.reload.start_date).to eq jan2022
# This cadence doesn't have an iteration. Its start date should be left as it is.
expect(cadence2.reload.start_date).to eq may2022
# This cadence has an invalid start date but it isn't automatic. Its start date should be left as it is.
expect(cadence3.reload.start_date).to eq jan2022
# This cadence has an invalid start date. Its start date should be fixed.
expect(cadence4.reload.start_date).to eq feb2022
end
end
end

View file

@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'Query.ciConfig' do
include GraphqlHelpers
include StubRequests
subject(:post_graphql_query) { post_graphql(query, current_user: user) }
@ -308,7 +309,7 @@ RSpec.describe 'Query.ciConfig' do
"when" => "on_success",
"tags" => [],
"needs" => { "nodes" => [] }
}
}
]
}
},
@ -343,4 +344,101 @@ RSpec.describe 'Query.ciConfig' do
)
end
end
context 'when the config file has multiple includes' do
let_it_be(:other_project) { create(:project, :repository, creator: user, namespace: user.namespace) }
let_it_be(:content) do
YAML.dump(
include: [
{ local: 'other_file.yml' },
{ remote: 'https://gitlab.com/gitlab-org/gitlab/raw/1234/.hello.yml' },
{ file: 'other_project_file.yml', project: other_project.full_path },
{ template: 'Jobs/Build.gitlab-ci.yml' }
],
rspec: {
script: 'rspec'
}
)
end
let(:remote_file_content) do
YAML.dump(
remote_file_test: {
script: 'remote_file_test'
}
)
end
before do
allow_next_instance_of(Repository) do |repository|
allow(repository).to receive(:blob_data_at).with(an_instance_of(String), 'other_file.yml') do
YAML.dump(
build: {
script: 'build'
}
)
end
allow(repository).to receive(:blob_data_at).with(an_instance_of(String), 'other_project_file.yml') do
YAML.dump(
other_project_test: {
script: 'other_project_test'
}
)
end
end
stub_full_request('https://gitlab.com/gitlab-org/gitlab/raw/1234/.hello.yml').to_return(body: remote_file_content)
post_graphql_query
end
it_behaves_like 'a working graphql query'
# rubocop:disable Layout/LineLength
it 'returns correct includes' do
expect(graphql_data['ciConfig']["includes"]).to eq(
[
{
"type" => "local",
"location" => "other_file.yml",
"blob" => "http://localhost/#{project.full_path}/-/blob/#{project.commit.sha}/other_file.yml",
"raw" => "http://localhost/#{project.full_path}/-/raw/#{project.commit.sha}/other_file.yml",
"extra" => {},
"contextProject" => project.full_path,
"contextSha" => project.commit.sha
},
{
"type" => "remote",
"location" => "https://gitlab.com/gitlab-org/gitlab/raw/1234/.hello.yml",
"blob" => nil,
"raw" => "https://gitlab.com/gitlab-org/gitlab/raw/1234/.hello.yml",
"extra" => {},
"contextProject" => project.full_path,
"contextSha" => project.commit.sha
},
{
"type" => "file",
"location" => "other_project_file.yml",
"blob" => "http://localhost/#{other_project.full_path}/-/blob/#{other_project.commit.sha}/other_project_file.yml",
"raw" => "http://localhost/#{other_project.full_path}/-/raw/#{other_project.commit.sha}/other_project_file.yml",
"extra" => { "project" => other_project.full_path, "ref" => "HEAD" },
"contextProject" => project.full_path,
"contextSha" => project.commit.sha
},
{
"type" => "template",
"location" => "Jobs/Build.gitlab-ci.yml",
"blob" => nil,
"raw" => "https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml",
"extra" => {},
"contextProject" => project.full_path,
"contextSha" => project.commit.sha
}
]
)
end
# rubocop:enable Layout/LineLength
end
end

View file

@ -20,6 +20,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
let(:source_branch) { 'fix' }
let(:target_branch) { 'feature' }
let(:title) { 'my title' }
let(:draft_title) { 'Draft: my title' }
let(:draft) { true }
let(:description) { 'my description' }
let(:multiline_description) do
<<~MD.chomp
@ -82,6 +84,16 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
end
end
shared_examples_for 'a service that can set the draft of a merge request' do
subject(:last_mr) { MergeRequest.last }
it 'sets the draft' do
service.execute
expect(last_mr.draft).to eq(draft)
end
end
shared_examples_for 'a service that can set the milestone of a merge request' do
subject(:last_mr) { MergeRequest.last }
@ -448,6 +460,67 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'with the project default branch'
end
describe '`draft` push option' do
let(:push_options) { { draft: draft } }
context 'with a new branch' do
let(:changes) { new_branch_changes }
it_behaves_like 'a service that does not create a merge request'
it 'adds an error to the service' do
service.execute
expect(service.errors).to include(error_mr_required)
end
context 'when coupled with the `create` push option' do
let(:push_options) { { create: true, draft: draft } }
it_behaves_like 'a service that can create a merge request'
it_behaves_like 'a service that can set the draft of a merge request'
end
end
context 'with an existing branch but no open MR' do
let(:changes) { existing_branch_changes }
it_behaves_like 'a service that does not create a merge request'
it 'adds an error to the service' do
service.execute
expect(service.errors).to include(error_mr_required)
end
context 'when coupled with the `create` push option' do
let(:push_options) { { create: true, draft: draft } }
it_behaves_like 'a service that can create a merge request'
it_behaves_like 'a service that can set the draft of a merge request'
end
end
context 'with an existing branch that has a merge request open' do
let(:changes) { existing_branch_changes }
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: source_branch)}
it_behaves_like 'a service that does not create a merge request'
it_behaves_like 'a service that can set the draft of a merge request'
end
context 'draft title provided while `draft` push option is set to false' do
let(:push_options) { { create: true, draft: false, title: draft_title } }
let(:changes) { new_branch_changes }
it_behaves_like 'a service that can create a merge request'
it_behaves_like 'a service that can set the draft of a merge request'
end
it_behaves_like 'with a deleted branch'
it_behaves_like 'with the project default branch'
end
describe '`label` push option' do
let(:push_options) { { label: { label1 => 1, label2 => 1 } } }

View file

@ -27,7 +27,7 @@ end
RSpec.shared_examples 'sidebar includes snowplow attributes' do |track_action, track_label, track_property|
specify do
allow(view).to receive(:tracking_enabled?).and_return(true)
stub_application_setting(snowplow_enabled: true)
render