Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
f1d9023a90
commit
8e180c115d
|
@ -559,7 +559,9 @@
|
|||
rules:
|
||||
- <<: *if-dot-com-ee-schedule
|
||||
changes: *code-backstage-patterns
|
||||
when: on_success
|
||||
- changes:
|
||||
- ".gitlab/ci/test-metadata.gitlab-ci.yml"
|
||||
- "scripts/rspec_helpers.sh"
|
||||
|
||||
##############
|
||||
# YAML rules #
|
||||
|
|
|
@ -31,6 +31,19 @@ update-tests-metadata:
|
|||
- .tests-metadata-state
|
||||
- .test-metadata:rules:update-tests-metadata
|
||||
stage: post-test
|
||||
dependencies:
|
||||
- setup-test-env pg11
|
||||
- rspec migration pg11
|
||||
- rspec unit pg11
|
||||
- rspec integration pg11
|
||||
- rspec system pg11
|
||||
- rspec-ee migration pg11
|
||||
- rspec-ee unit pg11
|
||||
- rspec-ee integration pg11
|
||||
- rspec-ee system pg11
|
||||
- rspec-ee unit pg11 geo
|
||||
- rspec-ee integration pg11 geo
|
||||
- rspec-ee system pg11 geo
|
||||
cache:
|
||||
policy: push
|
||||
script:
|
||||
|
|
|
@ -43,7 +43,7 @@ export default {
|
|||
update(data) {
|
||||
return this.snippet.project
|
||||
? data.project.userPermissions.createSnippet
|
||||
: data.currentUser.userPermissions.createSnippet;
|
||||
: data.currentUser?.userPermissions.createSnippet;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -196,7 +196,7 @@ module IssuablesHelper
|
|||
author_output = link_to_member(project, issuable.author, size: 24, mobile_classes: "d-none d-sm-inline")
|
||||
author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "d-inline d-sm-none")
|
||||
|
||||
author_output << gitlab_team_member_badge(issuable.author, css_class: 'ml-1')
|
||||
author_output << issuable_meta_author_slot(issuable.author, css_class: 'ml-1')
|
||||
|
||||
if status = user_status(issuable.author)
|
||||
author_output << "#{status}".html_safe
|
||||
|
@ -213,6 +213,11 @@ module IssuablesHelper
|
|||
output.join.html_safe
|
||||
end
|
||||
|
||||
# This is a dummy method, and has an override defined in ee
|
||||
def issuable_meta_author_slot(author, css_class: nil)
|
||||
nil
|
||||
end
|
||||
|
||||
def issuable_labels_tooltip(labels, limit: 5)
|
||||
first, last = labels.partition.with_index { |_, i| i < limit }
|
||||
|
||||
|
@ -242,27 +247,6 @@ module IssuablesHelper
|
|||
html.html_safe
|
||||
end
|
||||
|
||||
def gitlab_team_member_badge(author, css_class: nil)
|
||||
return unless author.gitlab_employee?
|
||||
|
||||
default_css_class = 'd-inline-block align-middle'
|
||||
gitlab_team_member = _('GitLab Team Member')
|
||||
|
||||
content_tag(
|
||||
:span,
|
||||
class: css_class ? "#{default_css_class} #{css_class}" : default_css_class,
|
||||
data: { toggle: 'tooltip', title: gitlab_team_member, container: 'body' },
|
||||
role: 'img',
|
||||
aria: { label: gitlab_team_member }
|
||||
) do
|
||||
sprite_icon(
|
||||
'tanuki-verified',
|
||||
size: 16,
|
||||
css_class: 'gl-text-purple d-block'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def issuable_first_contribution_icon
|
||||
content_tag(:span, class: 'fa-stack') do
|
||||
concat(icon('certificate', class: "fa-stack-2x"))
|
||||
|
|
|
@ -683,6 +683,10 @@ class User < ApplicationRecord
|
|||
without_ghosts.with_project_bots
|
||||
end
|
||||
|
||||
def human?
|
||||
user_type.nil?
|
||||
end
|
||||
|
||||
#
|
||||
# Instance methods
|
||||
#
|
||||
|
@ -1700,16 +1704,6 @@ class User < ApplicationRecord
|
|||
callouts.any?
|
||||
end
|
||||
|
||||
def gitlab_employee?
|
||||
strong_memoize(:gitlab_employee) do
|
||||
if Feature.enabled?(:gitlab_employee_badge) && Gitlab.com?
|
||||
Mail::Address.new(email).domain == "gitlab.com" && confirmed?
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Load the current highest access by looking directly at the user's memberships
|
||||
def current_highest_access_level
|
||||
members.non_request.maximum(:access_level)
|
||||
|
@ -1719,10 +1713,6 @@ class User < ApplicationRecord
|
|||
!confirmed? && !confirmation_period_valid?
|
||||
end
|
||||
|
||||
def organization
|
||||
gitlab_employee? ? 'GitLab' : super
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# override, from Devise::Validatable
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NoteUserEntity < UserEntity
|
||||
expose :gitlab_employee?, as: :is_gitlab_employee, if: ->(user, options) { user.gitlab_employee? }
|
||||
|
||||
unexpose :web_url
|
||||
end
|
||||
|
||||
NoteUserEntity.prepend_if_ee('EE::NoteUserEntity')
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
- else
|
||||
= f.text_field :location, label: s_('Profiles|Location'), class: 'input-lg', placeholder: s_("Profiles|City, country")
|
||||
= f.text_field :job_title, class: 'input-md'
|
||||
= f.text_field :organization, readonly: @user.gitlab_employee?, label: s_('Profiles|Organization'), class: 'input-md', help: s_("Profiles|Who you represent or work for")
|
||||
= render 'shared/profiles/organization', { form: f, user: @user }
|
||||
= f.text_area :bio, label: s_('Profiles|Bio'), rows: 4, maxlength: 250, help: s_("Profiles|Tell us about yourself in fewer than 250 characters")
|
||||
%hr
|
||||
%h5= s_("Private profile")
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
·
|
||||
opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')}
|
||||
by #{link_to_member(@project, issue.author, avatar: false)}
|
||||
= gitlab_team_member_badge(issue.author)
|
||||
= render_if_exists 'shared/issuable/gitlab_team_member_badge', {author: issue.author}
|
||||
- if issue.milestone
|
||||
%span.issuable-milestone.d-none.d-sm-inline-block
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
·
|
||||
opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')}
|
||||
by #{link_to_member(@project, merge_request.author, avatar: false)}
|
||||
= gitlab_team_member_badge(merge_request.author)
|
||||
= render_if_exists 'shared/issuable/gitlab_team_member_badge', {author: merge_request.author}
|
||||
- if merge_request.milestone
|
||||
%span.issuable-milestone.d-none.d-sm-inline-block
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
= form.text_field :organization, label: s_('Profiles|Organization'), class: 'input-md', help: s_("Profiles|Who you represent or work for")
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fixed JS error for anonymous views of a snippet
|
||||
merge_request: 29854
|
||||
author:
|
||||
type: fixed
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
extends: existence
|
||||
message: "Remove profanity: '%s'"
|
||||
ignorecase: true
|
||||
level: error
|
||||
tokens:
|
||||
- 'arse(hole)?'
|
||||
- 'ass(hole)?'
|
||||
- 'bastard'
|
||||
- 'bitch'
|
||||
- 'bloody'
|
||||
- 'bollocks'
|
||||
- 'bugger'
|
||||
- 'cocksucker'
|
||||
- 'crap'
|
||||
- 'cunt'
|
||||
- 'damn'
|
||||
- 'eff(ing)?'
|
||||
- 'fart'
|
||||
- 'fuck(er|ing)?'
|
||||
- 'goddamn(it?|ed)'
|
||||
- 'hell'
|
||||
- 'horseshit'
|
||||
- 'motherfuck(ers?|ing)'
|
||||
- 'piss(ing)?'
|
||||
- 'shit'
|
||||
- 'tits'
|
||||
- 'turd'
|
||||
- 'twat'
|
||||
- 'wank(er|ing)?'
|
|
@ -0,0 +1,103 @@
|
|||
---
|
||||
type: reference
|
||||
description: "GitLab administrator: enable and disable GitLab features deployed behind feature flags"
|
||||
---
|
||||
|
||||
# Enable and disable GitLab features deployed behind feature flags **(CORE ONLY)**
|
||||
|
||||
GitLab adopted [feature flags strategies](../development/feature_flags/index.md)
|
||||
to deploy features in an early stage of development so that they can be
|
||||
incrementally rolled out.
|
||||
|
||||
Before making them permanently available, features can be deployed behind
|
||||
flags for a [number of reasons](../development/feature_flags/process.md#when-to-use-feature-flags), such as:
|
||||
|
||||
- To test the feature.
|
||||
- To get feedback from users and customers while in an early stage of the development of the feature.
|
||||
- To evaluate users adoption.
|
||||
- To evaluate how it impacts GitLab's performance.
|
||||
- To build it in smaller pieces throughout releases.
|
||||
|
||||
Features behind flags can be gradually rolled out, typically:
|
||||
|
||||
1. The feature starts disabled by default.
|
||||
1. The feature becomes enabled by default.
|
||||
1. The feature flag is removed.
|
||||
|
||||
These features can be enabled and disabled to allow or disallow users to use
|
||||
them. It can be done by GitLab administrators with access to GitLab Rails
|
||||
console.
|
||||
|
||||
If you used a certain feature and identified a bug, a misbehavior, or an
|
||||
error, it's very important that you **[provide feedback]** to GitLab as soon
|
||||
as possible so we can improve or fix it while behind a flag. When you upgrade
|
||||
GitLab to an earlier version, the feature flag status may change.
|
||||
|
||||
[provide feedback]: https://gitlab.com/gitlab-org/gitlab/issues/new?issue[title]=Docs%20-%20feature%20flag%20feedback%3A%20Feature%20Name&issue[description]=Describe%20the%20problem%20you%27ve%20encountered.%0A%0A%3C!--%20Don%27t%20edit%20below%20this%20line%20--%3E%0A%0A%2Flabel%20~%22docs%5C-comments%22%20
|
||||
|
||||
<!-- Note: the link identifier above was used to facilitate review and update. -->
|
||||
|
||||
NOTE: **Note:**
|
||||
Mind that features deployed behind feature flags may not be ready for
|
||||
production use. However, disabling features behind flags that were deployed
|
||||
enabled by default may also present a risk. If they're enabled, we recommend
|
||||
you leave them as-is.
|
||||
|
||||
## How to enable and disable features behind flags
|
||||
|
||||
Each feature has its own flag that should be used to enable and disable it.
|
||||
The documentation of each feature behind a flag includes a section informing
|
||||
the status of the flag and the command to enable or disable it.
|
||||
|
||||
### Start the GitLab Rails console
|
||||
|
||||
The first thing you need to enable or disable a feature behind a flag is to
|
||||
start a session on GitLab Rails console.
|
||||
|
||||
For Omnibus installations:
|
||||
|
||||
```shell
|
||||
sudo gitlab-rails console
|
||||
```
|
||||
|
||||
For installations from the source:
|
||||
|
||||
```shell
|
||||
sudo -u git -H bundle exec rails console -e production
|
||||
```
|
||||
|
||||
For details, see [starting a Rails console session](troubleshooting/debug.md#starting-a-rails-console-session).
|
||||
|
||||
### Enable or disable the feature
|
||||
|
||||
Once the Rails console session has started, run the `Feature.enable` or
|
||||
`Feature.disable` commands accordingly. The specific flag can be found
|
||||
in the feature's documentation itself.
|
||||
|
||||
To enable a feature, run:
|
||||
|
||||
```ruby
|
||||
Feature.enable(:<feature flag>)
|
||||
```
|
||||
|
||||
Example, to enable Evidence Collection:
|
||||
|
||||
```ruby
|
||||
Feature.enable(:release_evidence_collection)
|
||||
```
|
||||
|
||||
To disable a feature, run:
|
||||
|
||||
```ruby
|
||||
Feature.disable(:<feature flag>)
|
||||
```
|
||||
|
||||
Example, to disable Evidence Collection:
|
||||
|
||||
```ruby
|
||||
Feature.disable(:release_evidence_collection)
|
||||
```
|
||||
|
||||
When the feature is ready, GitLab will remove the feature flag, the option for
|
||||
enabling and disabling it will no longer exist, and the feature will become
|
||||
available in all instances.
|
|
@ -64,7 +64,8 @@ Learn how to install, configure, update, and maintain your GitLab instance.
|
|||
- [External Classification Policy Authorization](../user/admin_area/settings/external_authorization.md) **(PREMIUM ONLY)**
|
||||
- [Upload a license](../user/admin_area/license.md): Upload a license to unlock features that are in paid tiers of GitLab. **(STARTER ONLY)**
|
||||
- [Admin Area](../user/admin_area/index.md): for self-managed instance-wide configuration and maintenance.
|
||||
- [S/MIME Signing](smime_signing_email.md): how to sign all outgoing notification emails with S/MIME
|
||||
- [S/MIME Signing](smime_signing_email.md): how to sign all outgoing notification emails with S/MIME.
|
||||
- [Enabling and disabling features flags](feature_flags.md): how to enable and disable GitLab features deployed behind feature flags.
|
||||
|
||||
#### Customizing GitLab's appearance
|
||||
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
---
|
||||
type: reference
|
||||
description: "GitLab development - how to document features deployed behind feature flags"
|
||||
---
|
||||
|
||||
# Document features deployed behind feature flags
|
||||
|
||||
GitLab uses [Feature Flags](../feature_flags/index.md) to strategically roll
|
||||
out the deployment of its own features. The way we document a feature behind a
|
||||
feature flag depends on its state (enabled or disabled). When the state
|
||||
changes, the developer who made the change **must update the documentation**
|
||||
accordingly.
|
||||
|
||||
## Criteria
|
||||
|
||||
According to the process of [deploying GitLab features behind feature flags](../feature_flags/process.md):
|
||||
|
||||
> - _By default, feature flags should be off._
|
||||
> - _Feature flags should remain in the codebase for a short period as possible to reduce the need for feature flag accounting._
|
||||
> - _In order to build a final release and present the feature for self-managed users, the feature flag should be at least defaulted to on._
|
||||
|
||||
See how to document them below, according to the state of the flag:
|
||||
|
||||
- [Features disabled by default](#features-disabled-by-default).
|
||||
- [Features that became enabled by default](#features-that-became-enabled-by-default).
|
||||
- [Features directly enabled by default](#features-directly-enabled-by-default).
|
||||
- [Features with the feature flag removed](#features-with-flag-removed).
|
||||
|
||||
NOTE: **Note:**
|
||||
The [`**(CORE ONLY)**`](styleguide.md#product-badges) badge or equivalent for
|
||||
the feature's tier should be added to the line and heading that refers to
|
||||
enabling/disabling feature flags as Admin access is required to do so,
|
||||
therefore, it indicates that it cannot be done by regular users of GitLab.com.
|
||||
|
||||
### Features disabled by default
|
||||
|
||||
For features disabled by default, if they cannot be used yet due to lack of
|
||||
completeness, or if they're still under internal evaluation (for example, for
|
||||
performance implications) do **not document them**: add (or merge) the docs
|
||||
only when the feature is safe and ready to use and test by end users.
|
||||
|
||||
For feature flags disabled by default, if they can be used by end users:
|
||||
|
||||
- Say that it's disabled by default.
|
||||
- Say whether it's enabled on GitLab.com.
|
||||
- Say whether it's recommended for production use.
|
||||
- Document how to enable and disable it.
|
||||
|
||||
For example, for a feature disabled by default, disabled on GitLab.com, and
|
||||
not ready for production use:
|
||||
|
||||
````md
|
||||
# Feature Name
|
||||
|
||||
> - [Introduced](link-to-issue) in GitLab 12.0.
|
||||
> - It's deployed behind a feature flag, disabled by default.
|
||||
> - It's disabled on GitLab.com.
|
||||
> - It's not recommended for production use.
|
||||
> - To use it in GitLab self-managed instances, ask a GitLab administrator to [enable it](#anchor-to-section). **(CORE ONLY)**
|
||||
|
||||
(...)
|
||||
|
||||
### Enable or disable <Feature Name> **(CORE ONLY)**
|
||||
|
||||
<Feature Name> is under development and not ready for production use. It is
|
||||
deployed behind a feature flag that is **disabled by default**.
|
||||
[GitLab administrators with access to the GitLab Rails console](../path/to/administration/feature_flags.md)
|
||||
can enable it for your instance.
|
||||
|
||||
To enable it:
|
||||
|
||||
```ruby
|
||||
Feature.enable(:<feature flag>)
|
||||
```
|
||||
|
||||
To disable it:
|
||||
|
||||
```ruby
|
||||
Feature.disable(:<feature flag>)
|
||||
```
|
||||
````
|
||||
|
||||
Adjust the blurb according to the state of the feature you're documenting.
|
||||
|
||||
### Features that became enabled by default
|
||||
|
||||
For features that became enabled by default:
|
||||
|
||||
- Say that it became enabled by default.
|
||||
- Say whether it's enabled on GitLab.com.
|
||||
- Say whether it's recommended for production use.
|
||||
- Document how to disable and enable it.
|
||||
|
||||
For example, for a feature initially deployed disabled by default, that became enabled by default, that is enabled on GitLab.com, and ready for production use:
|
||||
|
||||
````md
|
||||
# Feature Name
|
||||
|
||||
> - [Introduced](link-to-issue) in GitLab 12.0.
|
||||
> - It was deployed behind a feature flag, disabled by default.
|
||||
> - [Became enabled by default](link-to-issue) on GitLab 12.1.
|
||||
> - It's enabled on GitLab.com.
|
||||
> - It's recommended for production use.
|
||||
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#anchor-to-section). **(CORE ONLY)**
|
||||
|
||||
(...)
|
||||
|
||||
### Enable or disable <Feature Name> **(CORE ONLY)**
|
||||
|
||||
<Feature Name> is under development but ready for production use.
|
||||
It is deployed behind a feature flag that is **enabled by default**.
|
||||
[GitLab administrators with access to the GitLab Rails console](..path/to/administration/feature_flags.md)
|
||||
can opt to disable it for your instance.
|
||||
|
||||
To disable it:
|
||||
|
||||
```ruby
|
||||
Feature.disable(:<feature flag>)
|
||||
```
|
||||
|
||||
To enable it:
|
||||
|
||||
```ruby
|
||||
Feature.enable(:<feature flag>)
|
||||
```
|
||||
````
|
||||
|
||||
Adjust the blurb according to the state of the feature you're documenting.
|
||||
|
||||
### Features directly enabled by default
|
||||
|
||||
For features enabled by default:
|
||||
|
||||
- Say it's enabled by default.
|
||||
- Say whether it's enabled on GitLab.com.
|
||||
- Say whether it's recommended for production use.
|
||||
- Document how to disable and enable it.
|
||||
|
||||
For example, for a feature enabled by default, enabled on GitLab.com, and ready for production use:
|
||||
|
||||
````md
|
||||
# Feature Name
|
||||
|
||||
> - [Introduced](link-to-issue) in GitLab 12.0.
|
||||
> - It's deployed behind a feature flag, enabled by default.
|
||||
> - It's enabled on GitLab.com.
|
||||
> - It's recommended for production use.
|
||||
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#anchor-to-section). **(CORE ONLY)**
|
||||
|
||||
(...)
|
||||
|
||||
### Enable or disable <Feature Name> **(CORE ONLY)**
|
||||
|
||||
<Feature Name> is under development but ready for production use.
|
||||
It is deployed behind a feature flag that is **enabled by default**.
|
||||
[GitLab administrators with access to the GitLab Rails console](..path/to/administration/feature_flags.md)
|
||||
can opt to disable it for your instance.
|
||||
|
||||
To disable it:
|
||||
|
||||
```ruby
|
||||
Feature.disable(:<feature flag>)
|
||||
```
|
||||
|
||||
To enable it:
|
||||
|
||||
```ruby
|
||||
Feature.enable(:<feature flag>)
|
||||
```
|
||||
````
|
||||
|
||||
Adjust the blurb according to the state of the feature you're documenting.
|
||||
|
||||
### Features with flag removed
|
||||
|
||||
Once the feature is ready and the flag has been removed, clean up the
|
||||
documentation. Remove the feature flag mention keeping only a note that
|
||||
mentions the flag in the version history notes:
|
||||
|
||||
````md
|
||||
# Feature Name
|
||||
|
||||
> - [Introduced](link-to-issue) in GitLab 12.0.
|
||||
> - [Feature flag removed](link-to-issue) in GitLab 12.2.
|
||||
|
||||
(...)
|
||||
|
||||
````
|
|
@ -13,6 +13,7 @@ In addition to this page, the following resources can help you craft and contrib
|
|||
- [Documentation process](workflow.md).
|
||||
- [Markdown Guide](../../user/markdown.md) - A reference for all Markdown syntax supported by GitLab.
|
||||
- [Site architecture](site_architecture/index.md) - How <https://docs.gitlab.com> is built.
|
||||
- [Documentation for feature flags](feature_flags.md) - How to write and update documentation for GitLab features deployed behind feature flags.
|
||||
|
||||
## Source files and rendered web locations
|
||||
|
||||
|
|
|
@ -1416,38 +1416,8 @@ can facilitate this by making sure the troubleshooting content addresses:
|
|||
|
||||
## Feature flags
|
||||
|
||||
Sometimes features are shipped with feature flags, either:
|
||||
|
||||
- On by default, but providing the option to turn the feature off.
|
||||
- Off by default, but providing the option to turn the feature on.
|
||||
|
||||
When documenting feature flags for a feature, include:
|
||||
|
||||
- Why a feature flag is necessary. Some of the reasons are
|
||||
[outlined in the handbook](https://about.gitlab.com/handbook/product/#alpha-beta-ga).
|
||||
- That administrative access is required to make a feature flag change.
|
||||
- What to ask for when requesting a change to a feature flag's state.
|
||||
|
||||
NOTE: **Note:**
|
||||
The [Product Manager for the relevant group](https://about.gitlab.com/handbook/product/categories/#devops-stages)
|
||||
must review and approve the addition or removal of any mentions of using feature flags before the doc change is merged.
|
||||
|
||||
The following is sample text for adding feature flag documentation for a feature that is
|
||||
off by default:
|
||||
|
||||
````md
|
||||
### Enabling the feature
|
||||
|
||||
This feature comes with the `:feature_flag` feature flag disabled by default. In some cases,
|
||||
this feature is incompatible with an old configuration. To turn on the feature,
|
||||
ask a GitLab administrator with Rails console access to run the following command:
|
||||
|
||||
```ruby
|
||||
Feature.enable(:feature_flag)
|
||||
```
|
||||
````
|
||||
|
||||
For guidance on developing with feature flags, see
|
||||
Learn how to [document features deployed behind flags](feature_flags.md).
|
||||
For guidance on developing GitLab with feature flags, see
|
||||
[Feature flags in development of GitLab](../feature_flags/index.md).
|
||||
|
||||
## API
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Feature flags in development of GitLab
|
||||
|
||||
Feature flags can be used to gradually roll out changes, be
|
||||
[Feature Flags](../../user/project/operations/feature_flags.md)
|
||||
can be used to gradually roll out changes, be
|
||||
it a new feature, or a performance improvement. By using feature flags, we can
|
||||
comfortably measure the impact of our changes, while still being able to easily
|
||||
disable those changes, without having to revert an entire release.
|
||||
|
@ -10,6 +11,5 @@ Before using feature flags for GitLab's development, read through the following:
|
|||
- [Process for using features flags](process.md).
|
||||
- [Developing with feature flags](development.md).
|
||||
- [Controlling feature flags](controls.md).
|
||||
|
||||
When documenting feature flags, see [Feature flags](../documentation/styleguide.md#feature-flags)
|
||||
in the Documentation Style Guide.
|
||||
- [Documenting features deployed behind feature flags](../documentation/feature_flags.md).
|
||||
- [How GitLab administrators can enable and disable features behind flags](../../administration/feature_flags.md).
|
||||
|
|
|
@ -63,6 +63,9 @@ from when the merge request is first reviewed to when the change is deployed to
|
|||
GitLab.com. However, it is recommended to allow 10-14 days for this activity to
|
||||
account for unforeseen problems.
|
||||
|
||||
Feature flags must be [documented according to their state (enabled/disabled)](../documentation/feature_flags.md),
|
||||
and when the state changes, docs **must** be updated accordingly.
|
||||
|
||||
NOTE: **Note:**
|
||||
Take into consideration that such action can make the feature available on
|
||||
GitLab.com shortly after the change to the feature flag is merged.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
While [Auto DevOps](index.md) provides great defaults to get you started, you can customize
|
||||
almost everything to fit your needs. Auto DevOps offers everything from custom
|
||||
[buildpacks](#custom-buildpacks), to [`Dockerfiles](#custom-dockerfile), and
|
||||
[buildpacks](#custom-buildpacks), to [Dockerfiles](#custom-dockerfile), and
|
||||
[Helm charts](#custom-helm-chart). You can even copy the complete
|
||||
[CI/CD configuration](#customizing-gitlab-ciyml) into your project to enable
|
||||
staging and canary deployments, and more.
|
||||
|
@ -318,7 +318,7 @@ applications.
|
|||
| `CANARY_REPLICAS` | Number of canary replicas to deploy for [Canary Deployments](../../user/project/canary_deployments.md). Defaults to 1. |
|
||||
| `HELM_RELEASE_NAME` | From GitLab 12.1, allows the `helm` release name to be overridden. Can be used to assign unique release names when deploying multiple projects to a single namespace. |
|
||||
| `HELM_UPGRADE_VALUES_FILE` | From GitLab 12.6, allows the `helm upgrade` values file to be overridden. Defaults to `.gitlab/auto-deploy-values.yaml`. |
|
||||
| `HELM_UPGRADE_EXTRA_ARGS` | From GitLab 11.11, allows extra arguments in `helm` commands when deploying the application. Note that using quotes won't prevent word splitting. **Tip:** you can use this variable to [customize the Auto Deploy Helm chart](#custom-helm-chart) by applying custom override values with `--values my-values.yaml`. |
|
||||
| `HELM_UPGRADE_EXTRA_ARGS` | From GitLab 11.11, allows extra arguments in `helm` commands when deploying the application. Note that using quotes won't prevent word splitting. |
|
||||
| `INCREMENTAL_ROLLOUT_MODE` | From GitLab 11.4, if present, can be used to enable an [incremental rollout](#incremental-rollout-to-production-premium) of your application for the production environment. Set to `manual` for manual deployment jobs or `timed` for automatic rollout deployments with a 5 minute delay each one. |
|
||||
| `K8S_SECRET_*` | From GitLab 11.7, any variable prefixed with [`K8S_SECRET_`](#application-secret-variables) will be made available by Auto DevOps as environment variables to the deployed application. |
|
||||
| `KUBE_INGRESS_BASE_DOMAIN` | From GitLab 11.8, can be used to set a domain per cluster. See [cluster domains](../../user/project/clusters/index.md#base-domain) for more information. |
|
||||
|
@ -329,9 +329,9 @@ applications.
|
|||
| `STAGING_ENABLED` | From GitLab 10.8, used to define a [deploy policy for staging and production environments](#deploy-policy-for-staging-and-production-environments). |
|
||||
|
||||
TIP: **Tip:**
|
||||
Set up the replica variables using a
|
||||
[project variable](../../ci/variables/README.md#gitlab-cicd-environment-variables)
|
||||
and scale your application by only redeploying it.
|
||||
After you set up your replica variables using a
|
||||
[project variable](../../ci/variables/README.md#gitlab-cicd-environment-variables),
|
||||
you can scale your application by redeploying it.
|
||||
|
||||
CAUTION: **Caution:**
|
||||
You should *not* scale your application using Kubernetes directly. This can
|
||||
|
|
|
@ -59,7 +59,7 @@ We recommend setting the NameID format to `Persistent` unless using a field (suc
|
|||
|
||||
With this option enabled, users must use your group's GitLab single sign on URL to be added to the group or be added via SCIM. Users cannot be added manually, and may only access project/group resources via the UI by signing in through the SSO URL.
|
||||
|
||||
However, users will not be prompted to log via SSO on each visit. GitLab will check whether a user has authenticated through the SSO link, and will only prompt the user to login via SSO if it has been longer than 7 days.
|
||||
However, users will not be prompted to log via SSO on each visit. GitLab will check whether a user has authenticated through the SSO link, and will only prompt the user to login via SSO if the session has expired.
|
||||
|
||||
We intend to add a similar SSO requirement for [Git and API activity](https://gitlab.com/gitlab-org/gitlab/issues/9152) in the future.
|
||||
|
||||
|
|
|
@ -60,6 +60,11 @@ according to the type of domain you want to use with your Pages site:
|
|||
- [For subdomains](#for-subdomains), `subdomain.example.com`.
|
||||
- [For both](#for-both-root-and-subdomains).
|
||||
|
||||
NOTE: **Note:**
|
||||
IPv6 is not currently configured for Pages on GitLab.com, but
|
||||
you can [configure IPv6 on self-managed instances].(../../../../administration/pages/index.md#advanced-configuration).
|
||||
Follow [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/214718) for details.
|
||||
|
||||
##### For root domains
|
||||
|
||||
Root domains (`example.com`) require:
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Gitlab
|
||||
module Ci
|
||||
module Reports
|
||||
class AccessibilityReports
|
||||
attr_accessor :total, :passes, :errors
|
||||
attr_reader :urls
|
||||
|
||||
def initialize
|
||||
@urls = {}
|
||||
@total = 0
|
||||
@passes = 0
|
||||
@errors = 0
|
||||
end
|
||||
|
||||
def add_url(url, data)
|
||||
return if url.empty?
|
||||
|
||||
urls[url] = data
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,12 +14,11 @@ license_scanning:
|
|||
name: "registry.gitlab.com/gitlab-org/security-products/license-management:$LICENSE_MANAGEMENT_VERSION"
|
||||
entrypoint: [""]
|
||||
variables:
|
||||
LM_REPORT_FILE: gl-license-scanning-report.json
|
||||
SETUP_CMD: $LICENSE_MANAGEMENT_SETUP_CMD
|
||||
allow_failure: true
|
||||
script:
|
||||
- /run.sh analyze .
|
||||
after_script:
|
||||
- mv gl-license-management-report.json gl-license-scanning-report.json
|
||||
artifacts:
|
||||
reports:
|
||||
license_scanning: gl-license-scanning-report.json
|
||||
|
|
2
qa/qa.rb
2
qa/qa.rb
|
@ -39,7 +39,6 @@ module QA
|
|||
autoload :MailHog, 'qa/runtime/mail_hog'
|
||||
autoload :IPAddress, 'qa/runtime/ip_address'
|
||||
autoload :Search, 'qa/runtime/search'
|
||||
autoload :Project, 'qa/runtime/project'
|
||||
autoload :ApplicationSettings, 'qa/runtime/application_settings'
|
||||
|
||||
module API
|
||||
|
@ -88,6 +87,7 @@ module QA
|
|||
autoload :Tag, 'qa/resource/tag'
|
||||
autoload :ProjectMember, 'qa/resource/project_member'
|
||||
autoload :UserGPG, 'qa/resource/user_gpg'
|
||||
autoload :Visibility, 'qa/resource/visibility'
|
||||
|
||||
module Events
|
||||
autoload :Base, 'qa/resource/events/base'
|
||||
|
|
|
@ -7,11 +7,11 @@ module QA
|
|||
class Project < Base
|
||||
include Events::Project
|
||||
include Members
|
||||
include Visibility
|
||||
|
||||
attr_accessor :repository_storage # requires admin access
|
||||
attr_writer :initialize_with_readme
|
||||
attr_writer :auto_devops_enabled
|
||||
attr_writer :visibility
|
||||
|
||||
attribute :id
|
||||
attribute :name
|
||||
|
@ -19,6 +19,7 @@ module QA
|
|||
attribute :description
|
||||
attribute :standalone
|
||||
attribute :runners_token
|
||||
attribute :visibility
|
||||
|
||||
attribute :group do
|
||||
Group.fabricate!
|
||||
|
@ -50,7 +51,7 @@ module QA
|
|||
@description = 'My awesome project'
|
||||
@initialize_with_readme = false
|
||||
@auto_devops_enabled = false
|
||||
@visibility = 'public'
|
||||
@visibility = :public
|
||||
end
|
||||
|
||||
def name=(raw_name)
|
||||
|
@ -83,6 +84,10 @@ module QA
|
|||
"/projects/#{CGI.escape(path_with_namespace)}"
|
||||
end
|
||||
|
||||
def api_visibility_path
|
||||
"/projects/#{id}"
|
||||
end
|
||||
|
||||
def api_get_archive_path(type = 'tar.gz')
|
||||
"#{api_get_path}/repository/archive.#{type}"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module QA
|
||||
module Resource
|
||||
module Visibility
|
||||
def set_visibility(visibility)
|
||||
put Runtime::API::Request.new(api_client, api_visibility_path).url, { visibility: visibility }
|
||||
end
|
||||
|
||||
class VisibilityLevel
|
||||
%i(public internal private).each do |level|
|
||||
const_set(level.upcase, level)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module QA
|
||||
module Runtime
|
||||
module Project
|
||||
extend self
|
||||
extend Support::Api
|
||||
|
||||
def create_project(project_name, api_client, project_description = 'default')
|
||||
project = Resource::Project.fabricate_via_api! do |project|
|
||||
project.add_name_uuid = false
|
||||
project.name = project_name
|
||||
project.description = project_description
|
||||
project.api_client = api_client
|
||||
project.visibility = 'public'
|
||||
end
|
||||
project
|
||||
end
|
||||
|
||||
def push_file_to_project(target_project, file_name, file_content)
|
||||
Resource::Repository::ProjectPush.fabricate! do |push|
|
||||
push.project = target_project
|
||||
push.file_name = file_name
|
||||
push.file_content = file_content
|
||||
end
|
||||
end
|
||||
|
||||
def set_project_visibility(api_client, project_id, visibility)
|
||||
request = Runtime::API::Request.new(api_client, "/projects/#{project_id}")
|
||||
response = put request.url, visibility: visibility
|
||||
response.code.equal?(QA::Support::Api::HTTP_STATUS_OK)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -15,9 +15,13 @@ function retrieve_tests_metadata() {
|
|||
function update_tests_metadata() {
|
||||
echo "{}" > "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}"
|
||||
|
||||
scripts/merge-reports "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" knapsack/rspec*_pg9_*.json
|
||||
scripts/merge-reports "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" knapsack/rspec*.json
|
||||
if [[ -n "${TESTS_METADATA_S3_BUCKET}" ]]; then
|
||||
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}"
|
||||
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
|
||||
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}"
|
||||
else
|
||||
echo "Not uplaoding report to S3 as the pipeline is not a scheduled one."
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f knapsack/rspec*.json
|
||||
|
@ -28,12 +32,20 @@ function update_tests_metadata() {
|
|||
scripts/flaky_examples/prune-old-flaky-examples "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
|
||||
|
||||
if [[ -n ${TESTS_METADATA_S3_BUCKET} ]]; then
|
||||
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
|
||||
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
|
||||
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
|
||||
else
|
||||
echo "Not uploading report to S3 as the pipeline is not a scheduled one."
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f rspec_flaky/all_*.json rspec_flaky/new_*.json
|
||||
|
||||
scripts/insert-rspec-profiling-data
|
||||
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
|
||||
scripts/insert-rspec-profiling-data
|
||||
else
|
||||
echo "Not inserting profiling data as the pipeline is not a scheduled one."
|
||||
fi
|
||||
}
|
||||
|
||||
function rspec_simple_job() {
|
||||
|
@ -47,10 +59,10 @@ function rspec_simple_job() {
|
|||
}
|
||||
|
||||
function rspec_paralellized_job() {
|
||||
read -ra job_name <<< "$CI_JOB_NAME"
|
||||
read -ra job_name <<< "${CI_JOB_NAME}"
|
||||
local test_tool="${job_name[0]}"
|
||||
local test_level="${job_name[1]}"
|
||||
local database="${job_name[2]}"
|
||||
local report_name=$(echo "${CI_JOB_NAME}" | sed -E 's|[/ ]|_|g') # e.g. 'rspec unit pg11 1/24' would become 'rspec_unit_pg11_1_24'
|
||||
local rspec_opts="${1}"
|
||||
local spec_folder_prefix=""
|
||||
|
||||
|
@ -59,7 +71,7 @@ function rspec_paralellized_job() {
|
|||
fi
|
||||
|
||||
export KNAPSACK_LOG_LEVEL="debug"
|
||||
export KNAPSACK_REPORT_PATH="knapsack/${test_tool}_${test_level}_${database}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json"
|
||||
export KNAPSACK_REPORT_PATH="knapsack/${report_name}_report.json"
|
||||
|
||||
cp "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" "${KNAPSACK_REPORT_PATH}"
|
||||
|
||||
|
@ -74,8 +86,8 @@ function rspec_paralellized_job() {
|
|||
export KNAPSACK_GENERATE_REPORT="true"
|
||||
export FLAKY_RSPEC_GENERATE_REPORT="true"
|
||||
export SUITE_FLAKY_RSPEC_REPORT_PATH="${FLAKY_RSPEC_SUITE_REPORT_PATH}"
|
||||
export FLAKY_RSPEC_REPORT_PATH="rspec_flaky/all_${test_tool}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json"
|
||||
export NEW_FLAKY_RSPEC_REPORT_PATH="rspec_flaky/new_${test_tool}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json"
|
||||
export FLAKY_RSPEC_REPORT_PATH="rspec_flaky/all_${report_name}_report.json"
|
||||
export NEW_FLAKY_RSPEC_REPORT_PATH="rspec_flaky/new_${report_name}_report.json"
|
||||
|
||||
if [[ ! -f $FLAKY_RSPEC_REPORT_PATH ]]; then
|
||||
echo "{}" > "${FLAKY_RSPEC_REPORT_PATH}"
|
||||
|
@ -90,7 +102,7 @@ function rspec_paralellized_job() {
|
|||
|
||||
mkdir -p tmp/memory_test
|
||||
|
||||
export MEMORY_TEST_PATH="tmp/memory_test/${test_tool}_${test_level}_${database}_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_memory.csv"
|
||||
export MEMORY_TEST_PATH="tmp/memory_test/${report_name}_memory.csv"
|
||||
|
||||
knapsack rspec "-Ispec --color --format documentation --format RspecJunitFormatter --out junit_rspec.xml ${rspec_opts}"
|
||||
|
||||
|
|
|
@ -1515,61 +1515,6 @@ describe Projects::IssuesController do
|
|||
expect(note_json['author']['status_tooltip_html']).to be_present
|
||||
end
|
||||
|
||||
context 'is_gitlab_employee attribute' do
|
||||
subject { get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:com?).and_return(true)
|
||||
note_user = discussion.author
|
||||
note_user.update(email: email)
|
||||
note_user.confirm
|
||||
end
|
||||
|
||||
shared_examples 'non inclusion of gitlab employee badge' do
|
||||
it 'does not render the is_gitlab_employee attribute' do
|
||||
subject
|
||||
|
||||
note_json = json_response.first['notes'].first
|
||||
|
||||
expect(note_json['author']['is_gitlab_employee']).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is a gitlab employee' do
|
||||
let(:email) { 'test@gitlab.com' }
|
||||
|
||||
it 'renders the is_gitlab_employee attribute' do
|
||||
subject
|
||||
|
||||
note_json = json_response.first['notes'].first
|
||||
|
||||
expect(note_json['author']['is_gitlab_employee']).to be true
|
||||
end
|
||||
|
||||
context 'when feature flag is disabled' do
|
||||
before do
|
||||
stub_feature_flags(gitlab_employee_badge: false)
|
||||
end
|
||||
|
||||
it_behaves_like 'non inclusion of gitlab employee badge'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is not a gitlab employee' do
|
||||
let(:email) { 'test@example.com' }
|
||||
|
||||
it_behaves_like 'non inclusion of gitlab employee badge'
|
||||
|
||||
context 'when feature flag is disabled' do
|
||||
before do
|
||||
stub_feature_flags(gitlab_employee_badge: false)
|
||||
end
|
||||
|
||||
it_behaves_like 'non inclusion of gitlab employee badge'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not cause an extra query for the status' do
|
||||
control = ActiveRecord::QueryRecorder.new do
|
||||
get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
|
||||
|
|
|
@ -303,46 +303,4 @@ describe IssuablesHelper do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#gitlab_team_member_badge' do
|
||||
let(:issue) { build(:issue, author: user) }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:com?).and_return(true)
|
||||
end
|
||||
|
||||
context 'when `:gitlab_employee_badge` feature flag is disabled' do
|
||||
let(:user) { build(:user, email: 'test@gitlab.com') }
|
||||
|
||||
before do
|
||||
stub_feature_flags(gitlab_employee_badge: false)
|
||||
end
|
||||
|
||||
it 'returns nil' do
|
||||
expect(helper.gitlab_team_member_badge(issue.author)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when issue author is not a GitLab team member' do
|
||||
let(:user) { build(:user, email: 'test@example.com') }
|
||||
|
||||
it 'returns nil' do
|
||||
expect(helper.gitlab_team_member_badge(issue.author)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when issue author is a GitLab team member' do
|
||||
let(:user) { build(:user, email: 'test@gitlab.com') }
|
||||
|
||||
it 'returns span with svg icon' do
|
||||
expect(helper.gitlab_team_member_badge(issue.author)).to have_selector('span > svg')
|
||||
end
|
||||
|
||||
context 'when `css_class` parameter is passed' do
|
||||
it 'adds CSS classes' do
|
||||
expect(helper.gitlab_team_member_badge(issue.author, css_class: 'foo bar baz')).to have_selector('span.foo.bar.baz')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Ci::Reports::AccessibilityReports do
|
||||
let(:accessibility_report) { described_class.new }
|
||||
|
||||
describe '#add_url' do
|
||||
subject { accessibility_report.add_url(url, data) }
|
||||
|
||||
context 'when data has errors' do
|
||||
let(:url) { 'https://gitlab.com' }
|
||||
let(:data) do
|
||||
[
|
||||
{
|
||||
"code": "WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent",
|
||||
"type": "error",
|
||||
"typeCode": 1,
|
||||
"message": "Anchor element found with a valid href attribute, but no link content has been supplied.",
|
||||
"context": "<a href=\"/customers/worldline\">\n<svg viewBox=\"0 0 509 89\" xmln...</a>",
|
||||
"selector": "html > body > div:nth-child(9) > div:nth-child(2) > a:nth-child(17)",
|
||||
"runner": "htmlcs",
|
||||
"runnerExtras": {}
|
||||
},
|
||||
{
|
||||
"code": "WCAG2AA.Principle4.Guideline4_1.4_1_2.H91.A.NoContent",
|
||||
"type": "error",
|
||||
"typeCode": 1,
|
||||
"message": "Anchor element found with a valid href attribute, but no link content has been supplied.",
|
||||
"context": "<a href=\"/customers/equinix\">\n<svg xmlns=\"http://www.w3.org/...</a>",
|
||||
"selector": "html > body > div:nth-child(9) > div:nth-child(2) > a:nth-child(18)",
|
||||
"runner": "htmlcs",
|
||||
"runnerExtras": {}
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
it 'adds urls and data to accessibility report' do
|
||||
expect { subject }.not_to raise_error
|
||||
|
||||
expect(accessibility_report.urls.keys).to eq([url])
|
||||
expect(accessibility_report.urls.values.flatten.size).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when data does not have errors' do
|
||||
let(:url) { 'https://gitlab.com' }
|
||||
let(:data) { [] }
|
||||
|
||||
it 'adds data to accessibility report' do
|
||||
expect { subject }.not_to raise_error
|
||||
|
||||
expect(accessibility_report.urls.keys).to eq([url])
|
||||
expect(accessibility_report.urls.values.flatten.size).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when url does not exist' do
|
||||
let(:url) { '' }
|
||||
let(:data) { [{ message: "Protocol error (Page.navigate): Cannot navigate to invalid URL" }] }
|
||||
|
||||
it 'do not add data to accessibility report' do
|
||||
expect { subject }.not_to raise_error
|
||||
|
||||
expect(accessibility_report.urls).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4458,45 +4458,6 @@ describe User, :do_not_mock_admin_mode do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#gitlab_employee?' do
|
||||
using RSpec::Parameterized::TableSyntax
|
||||
|
||||
subject { user.gitlab_employee? }
|
||||
|
||||
where(:email, :is_com, :expected_result) do
|
||||
'test@gitlab.com' | true | true
|
||||
'test@example.com' | true | false
|
||||
'test@gitlab.com' | false | false
|
||||
'test@example.com' | false | false
|
||||
end
|
||||
|
||||
with_them do
|
||||
let(:user) { build(:user, email: email) }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:com?).and_return(is_com)
|
||||
end
|
||||
|
||||
it { is_expected.to be expected_result }
|
||||
end
|
||||
|
||||
context 'when email is of Gitlab and is not confirmed' do
|
||||
let(:user) { build(:user, email: 'test@gitlab.com', confirmed_at: nil) }
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context 'when `:gitlab_employee_badge` feature flag is disabled' do
|
||||
let(:user) { build(:user, email: 'test@gitlab.com') }
|
||||
|
||||
before do
|
||||
stub_feature_flags(gitlab_employee_badge: false)
|
||||
end
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#current_highest_access_level' do
|
||||
let_it_be(:user) { create(:user) }
|
||||
|
||||
|
@ -4517,27 +4478,6 @@ describe User, :do_not_mock_admin_mode do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#organization' do
|
||||
using RSpec::Parameterized::TableSyntax
|
||||
|
||||
let(:user) { build(:user, organization: 'ACME') }
|
||||
|
||||
subject { user.organization }
|
||||
|
||||
where(:gitlab_employee?, :expected_result) do
|
||||
true | 'GitLab'
|
||||
false | 'ACME'
|
||||
end
|
||||
|
||||
with_them do
|
||||
before do
|
||||
allow(user).to receive(:gitlab_employee?).and_return(gitlab_employee?)
|
||||
end
|
||||
|
||||
it { is_expected.to eql(expected_result) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when after_commit :update_highest_role' do
|
||||
describe 'create user' do
|
||||
subject { create(:user) }
|
||||
|
@ -4685,4 +4625,26 @@ describe User, :do_not_mock_admin_mode do
|
|||
it_behaves_like 'does not require password to be present'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#human?' do
|
||||
subject { user.human? }
|
||||
|
||||
let_it_be(:user) { create(:user) }
|
||||
|
||||
context 'when user is a human' do
|
||||
before do
|
||||
user.update(user_type: nil)
|
||||
end
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
|
||||
context 'when user is not a human' do
|
||||
before do
|
||||
user.update(user_type: 'alert_bot')
|
||||
end
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
shared_context 'merge request show action' do
|
||||
include Devise::Test::ControllerHelpers
|
||||
include ProjectForksHelper
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, :public, :repository) }
|
||||
let(:forked_project) { fork_project(project, user, repository: true) }
|
||||
let(:unlink_project) { Projects::UnlinkForkService.new(forked_project, user) }
|
||||
let(:note) { create(:note_on_merge_request, project: project, noteable: closed_merge_request) }
|
||||
|
||||
let(:closed_merge_request) do
|
||||
create(:closed_merge_request,
|
||||
source_project: forked_project,
|
||||
target_project: project,
|
||||
author: user)
|
||||
end
|
||||
|
||||
def preload_view_requirements
|
||||
# This will load the status fields of the author of the note and merge request
|
||||
# to avoid queries in when rendering the view being tested.
|
||||
closed_merge_request.author.status
|
||||
note.author.status
|
||||
end
|
||||
|
||||
before do
|
||||
assign(:project, project)
|
||||
assign(:merge_request, closed_merge_request)
|
||||
assign(:commits_count, 0)
|
||||
assign(:note, note)
|
||||
assign(:noteable, closed_merge_request)
|
||||
assign(:notes, [])
|
||||
assign(:pipelines, Ci::Pipeline.none)
|
||||
assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request))
|
||||
|
||||
preload_view_requirements
|
||||
|
||||
allow(view).to receive_messages(current_user: user,
|
||||
can?: true,
|
||||
current_application_settings: Gitlab::CurrentSettings.current_application_settings)
|
||||
end
|
||||
|
||||
def serialize_issuable_sidebar(user, project, merge_request)
|
||||
MergeRequestSerializer
|
||||
.new(current_user: user, project: project)
|
||||
.represent(closed_merge_request, serializer: 'sidebar')
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
shared_context 'project show action' do
|
||||
let(:project) { create(:project, :repository) }
|
||||
let(:issue) { create(:issue, project: project, author: user) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
assign(:project, project)
|
||||
assign(:issue, issue)
|
||||
assign(:noteable, issue)
|
||||
stub_template 'shared/issuable/_sidebar' => ''
|
||||
stub_template 'projects/issues/_discussion' => ''
|
||||
allow(view).to receive(:user_status).and_return('')
|
||||
end
|
||||
end
|
|
@ -19,48 +19,4 @@ describe 'profiles/show' do
|
|||
expect(rendered).to have_field('user_id', with: user.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'gitlab.com organization field' do
|
||||
before do
|
||||
allow(Gitlab).to receive(:com?).and_return(true)
|
||||
end
|
||||
|
||||
context 'when `:gitlab_employee_badge` feature flag is enabled' do
|
||||
context 'and when user has an `@gitlab.com` email address' do
|
||||
let(:user) { create(:user, email: 'test@gitlab.com') }
|
||||
|
||||
it 'displays the organization field as `readonly` with a `value` of `GitLab`' do
|
||||
render
|
||||
|
||||
expect(rendered).to have_selector('#user_organization[readonly][value="GitLab"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'and when a user does not have an `@gitlab.com` email' do
|
||||
let(:user) { create(:user, email: 'test@example.com') }
|
||||
|
||||
it 'displays an editable organization field' do
|
||||
render
|
||||
|
||||
expect(rendered).to have_selector('#user_organization:not([readonly]):not([value="GitLab"])')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when `:gitlab_employee_badge` feature flag is disabled' do
|
||||
before do
|
||||
stub_feature_flags(gitlab_employee_badge: false)
|
||||
end
|
||||
|
||||
context 'and when a user has an `@gitlab.com` email' do
|
||||
let(:user) { create(:user, email: 'test@gitlab.com') }
|
||||
|
||||
it 'displays an editable organization field' do
|
||||
render
|
||||
|
||||
expect(rendered).to have_selector('#user_organization:not([readonly]):not([value="GitLab"])')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,18 +3,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'projects/issues/show' do
|
||||
let(:project) { create(:project, :repository) }
|
||||
let(:issue) { create(:issue, project: project, author: user) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
assign(:project, project)
|
||||
assign(:issue, issue)
|
||||
assign(:noteable, issue)
|
||||
stub_template 'shared/issuable/_sidebar' => ''
|
||||
stub_template 'projects/issues/_discussion' => ''
|
||||
allow(view).to receive(:user_status).and_return('')
|
||||
end
|
||||
include_context 'project show action'
|
||||
|
||||
context 'when the issue is closed' do
|
||||
before do
|
||||
|
@ -152,18 +141,4 @@ describe 'projects/issues/show' do
|
|||
expect(rendered).not_to have_selector('#js-sentry-error-stack-trace')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when issue is created by a GitLab team member' do
|
||||
let(:user) { create(:user, email: 'test@gitlab.com') }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:com?).and_return(true)
|
||||
end
|
||||
|
||||
it 'renders an employee badge next to their name' do
|
||||
render
|
||||
|
||||
expect(rendered).to have_selector('[aria-label="GitLab Team Member"]')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,45 +3,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'projects/merge_requests/show.html.haml' do
|
||||
include Devise::Test::ControllerHelpers
|
||||
include ProjectForksHelper
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, :public, :repository) }
|
||||
let(:forked_project) { fork_project(project, user, repository: true) }
|
||||
let(:unlink_project) { Projects::UnlinkForkService.new(forked_project, user) }
|
||||
let(:note) { create(:note_on_merge_request, project: project, noteable: closed_merge_request) }
|
||||
|
||||
let(:closed_merge_request) do
|
||||
create(:closed_merge_request,
|
||||
source_project: forked_project,
|
||||
target_project: project,
|
||||
author: user)
|
||||
end
|
||||
|
||||
def preload_view_requirements
|
||||
# This will load the status fields of the author of the note and merge request
|
||||
# to avoid queries in when rendering the view being tested.
|
||||
closed_merge_request.author.status
|
||||
note.author.status
|
||||
end
|
||||
|
||||
before do
|
||||
assign(:project, project)
|
||||
assign(:merge_request, closed_merge_request)
|
||||
assign(:commits_count, 0)
|
||||
assign(:note, note)
|
||||
assign(:noteable, closed_merge_request)
|
||||
assign(:notes, [])
|
||||
assign(:pipelines, Ci::Pipeline.none)
|
||||
assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request))
|
||||
|
||||
preload_view_requirements
|
||||
|
||||
allow(view).to receive_messages(current_user: user,
|
||||
can?: true,
|
||||
current_application_settings: Gitlab::CurrentSettings.current_application_settings)
|
||||
end
|
||||
include_context 'merge request show action'
|
||||
|
||||
describe 'merge request assignee sidebar' do
|
||||
context 'when assignee is allowed to merge' do
|
||||
|
@ -92,24 +54,4 @@ describe 'projects/merge_requests/show.html.haml' do
|
|||
expect(rendered).to have_css('a', visible: false, text: 'Close')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when merge request is created by a GitLab team member' do
|
||||
let(:user) { create(:user, email: 'test@gitlab.com') }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:com?).and_return(true)
|
||||
end
|
||||
|
||||
it 'renders an employee badge next to their name' do
|
||||
render
|
||||
|
||||
expect(rendered).to have_selector('[aria-label="GitLab Team Member"]')
|
||||
end
|
||||
end
|
||||
|
||||
def serialize_issuable_sidebar(user, project, merge_request)
|
||||
MergeRequestSerializer
|
||||
.new(current_user: user, project: project)
|
||||
.represent(closed_merge_request, serializer: 'sidebar')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue