Commit 31f42749 authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-11-22

# Conflicts:
#	locale/gitlab.pot

[ci skip]
parents 0d47652a 7002752d
...@@ -84,7 +84,7 @@ export default class AjaxVariableList { ...@@ -84,7 +84,7 @@ export default class AjaxVariableList {
.catch(() => { .catch(() => {
loadingIcon.classList.toggle('hide', true); loadingIcon.classList.toggle('hide', true);
this.variableList.toggleEnableRow(true); this.variableList.toggleEnableRow(true);
Flash(s__('CiVariable|Error occured while saving variables')); Flash(s__('CiVariable|Error occurred while saving variables'));
}); });
} }
......
...@@ -82,7 +82,7 @@ export const getFileData = ( ...@@ -82,7 +82,7 @@ export const getFileData = (
.catch(() => { .catch(() => {
commit(types.TOGGLE_LOADING, { entry: file }); commit(types.TOGGLE_LOADING, { entry: file });
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occured whilst loading the file.'), text: __('An error occurred whilst loading the file.'),
action: payload => action: payload =>
dispatch('getFileData', payload).then(() => dispatch('setErrorMessage', null)), dispatch('getFileData', payload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
...@@ -124,7 +124,7 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) = ...@@ -124,7 +124,7 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) =
}) })
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occured whilst loading the file content.'), text: __('An error occurred whilst loading the file content.'),
action: payload => action: payload =>
dispatch('getRawFileData', payload).then(() => dispatch('setErrorMessage', null)), dispatch('getRawFileData', payload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
......
...@@ -25,7 +25,7 @@ export const getMergeRequestData = ( ...@@ -25,7 +25,7 @@ export const getMergeRequestData = (
}) })
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occured whilst loading the merge request.'), text: __('An error occurred whilst loading the merge request.'),
action: payload => action: payload =>
dispatch('getMergeRequestData', payload).then(() => dispatch('getMergeRequestData', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
...@@ -58,7 +58,7 @@ export const getMergeRequestChanges = ( ...@@ -58,7 +58,7 @@ export const getMergeRequestChanges = (
}) })
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occured whilst loading the merge request changes.'), text: __('An error occurred whilst loading the merge request changes.'),
action: payload => action: payload =>
dispatch('getMergeRequestChanges', payload).then(() => dispatch('getMergeRequestChanges', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
...@@ -92,7 +92,7 @@ export const getMergeRequestVersions = ( ...@@ -92,7 +92,7 @@ export const getMergeRequestVersions = (
}) })
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occured whilst loading the merge request version data.'), text: __('An error occurred whilst loading the merge request version data.'),
action: payload => action: payload =>
dispatch('getMergeRequestVersions', payload).then(() => dispatch('getMergeRequestVersions', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
......
...@@ -103,7 +103,7 @@ export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch) ...@@ -103,7 +103,7 @@ export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch)
}) })
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occured creating the new branch.'), text: __('An error occurred creating the new branch.'),
action: payload => dispatch('createNewBranchFromDefault', payload), action: payload => dispatch('createNewBranchFromDefault', payload),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: branch, actionPayload: branch,
......
...@@ -76,7 +76,7 @@ export const getFiles = ({ state, commit, dispatch }, { projectId, branchId } = ...@@ -76,7 +76,7 @@ export const getFiles = ({ state, commit, dispatch }, { projectId, branchId } =
dispatch('showBranchNotFoundError', branchId); dispatch('showBranchNotFoundError', branchId);
} else { } else {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occured whilst loading all the files.'), text: __('An error occurred whilst loading all the files.'),
action: payload => action: payload =>
dispatch('getFiles', payload).then(() => dispatch('setErrorMessage', null)), dispatch('getFiles', payload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
......
...@@ -28,7 +28,7 @@ export const receiveLatestPipelineError = ({ commit, dispatch }, err) => { ...@@ -28,7 +28,7 @@ export const receiveLatestPipelineError = ({ commit, dispatch }, err) => {
dispatch( dispatch(
'setErrorMessage', 'setErrorMessage',
{ {
text: __('An error occured whilst fetching the latest pipeline.'), text: __('An error occurred whilst fetching the latest pipeline.'),
action: () => action: () =>
dispatch('forcePipelineRequest').then(() => dispatch('forcePipelineRequest').then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
...@@ -84,7 +84,7 @@ export const receiveJobsError = ({ commit, dispatch }, stage) => { ...@@ -84,7 +84,7 @@ export const receiveJobsError = ({ commit, dispatch }, stage) => {
dispatch( dispatch(
'setErrorMessage', 'setErrorMessage',
{ {
text: __('An error occured whilst loading the pipelines jobs.'), text: __('An error occurred whilst loading the pipelines jobs.'),
action: payload => action: payload =>
dispatch('fetchJobs', payload).then(() => dispatch('fetchJobs', payload).then(() =>
dispatch('setErrorMessage', null, { root: true }), dispatch('setErrorMessage', null, { root: true }),
...@@ -123,7 +123,7 @@ export const receiveJobTraceError = ({ commit, dispatch }) => { ...@@ -123,7 +123,7 @@ export const receiveJobTraceError = ({ commit, dispatch }) => {
dispatch( dispatch(
'setErrorMessage', 'setErrorMessage',
{ {
text: __('An error occured whilst fetching the job trace.'), text: __('An error occurred whilst fetching the job trace.'),
action: () => action: () =>
dispatch('fetchJobTrace').then(() => dispatch('setErrorMessage', null, { root: true })), dispatch('fetchJobTrace').then(() => dispatch('setErrorMessage', null, { root: true })),
actionText: __('Please try again'), actionText: __('Please try again'),
......
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
errorMessage() { errorMessage() {
return sprintf( return sprintf(
s__( s__(
'ClusterIntegration|An error occured while trying to fetch zone machine types: %{error}', 'ClusterIntegration|An error occurred while trying to fetch zone machine types: %{error}',
), ),
{ error: this.gapiError }, { error: this.gapiError },
); );
......
...@@ -93,7 +93,7 @@ export default { ...@@ -93,7 +93,7 @@ export default {
} }
return sprintf( return sprintf(
s__('ClusterIntegration|An error occured while trying to fetch your projects: %{error}'), s__('ClusterIntegration|An error occurred while trying to fetch your projects: %{error}'),
{ error: this.gapiError }, { error: this.gapiError },
); );
}, },
......
---
title: 'SystemCheck: Use a more reliable way to detect current Ruby version'
merge_request: 23291
author:
type: changed
---
title: Update rack to 2.0.6 (for QA environments)
merge_request: 23171
author: Takuya Noguchi
type: security
---
title: Upgrade minimum required Git version to 2.18.0
merge_request: 22803
author:
type: other
---
title: Fix typo for scheduled pipeline
merge_request: 23218
author: Davy Defaud
type: other
---
title: Show what RPC is called in the performance bar
merge_request: 23140
author:
type: other
...@@ -668,7 +668,7 @@ POST /projects/:id/issues/:issue_iid/move ...@@ -668,7 +668,7 @@ POST /projects/:id/issues/:issue_iid/move
| `to_project_id` | integer | yes | The ID of the new project | | `to_project_id` | integer | yes | The ID of the new project |
```bash ```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --data '{"to_project_id": 5}' https://gitlab.example.com/api/v4/projects/4/issues/85/move curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form to_project_id=5 https://gitlab.example.com/api/v4/projects/4/issues/85/move
``` ```
Example response: Example response:
......
...@@ -1634,6 +1634,10 @@ rspec: ...@@ -1634,6 +1634,10 @@ rspec:
- bundle exec rspec - bundle exec rspec
``` ```
NOTE: **Note:**
`include` requires the external YAML files to have the extensions `.yml` or `.yaml`.
The external file will not be included if the extension is missing.
You can define it either as a single string, or, in case you want to include You can define it either as a single string, or, in case you want to include
more than one files, an array of different values . The following examples more than one files, an array of different values . The following examples
are both valid cases: are both valid cases:
......
...@@ -79,7 +79,7 @@ Make sure you have the right version of Git installed ...@@ -79,7 +79,7 @@ Make sure you have the right version of Git installed
# Install Git # Install Git
sudo apt-get install -y git-core sudo apt-get install -y git-core
# Make sure Git is version 2.9.5 or higher # Make sure Git is version 2.18.0 or higher
git --version git --version
Is the system packaged Git too old? Remove it and compile from source. Is the system packaged Git too old? Remove it and compile from source.
......
...@@ -4,92 +4,95 @@ This documentation is for enabling shibboleth with omnibus-gitlab package. ...@@ -4,92 +4,95 @@ This documentation is for enabling shibboleth with omnibus-gitlab package.
In order to enable Shibboleth support in gitlab we need to use Apache instead of Nginx (It may be possible to use Nginx, however this is difficult to configure using the bundled Nginx provided in the omnibus-gitlab package). Apache uses mod_shib2 module for shibboleth authentication and can pass attributes as headers to omniauth-shibboleth provider. In order to enable Shibboleth support in gitlab we need to use Apache instead of Nginx (It may be possible to use Nginx, however this is difficult to configure using the bundled Nginx provided in the omnibus-gitlab package). Apache uses mod_shib2 module for shibboleth authentication and can pass attributes as headers to omniauth-shibboleth provider.
To enable the Shibboleth OmniAuth provider you must configure Apache shibboleth module.
To enable the Shibboleth OmniAuth provider you must: Installation and configuration of module it self is out of scope of this document.
Check <https://wiki.shibboleth.net/> for more info.
1. Configure Apache shibboleth module. Installation and configuration of module it self is out of scope of this document.
Check https://wiki.shibboleth.net/ for more info. You can find Apache config in gitlab-recipes (<https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache>).
1. You can find Apache config in gitlab-recipes (https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache) The following changes are needed to enable Shibboleth:
Following changes are needed to enable shibboleth: 1. Protect omniauth-shibboleth callback URL:
protect omniauth-shibboleth callback URL: ```
``` <Location /users/auth/shibboleth/callback>
<Location /users/auth/shibboleth/callback> AuthType shibboleth
AuthType shibboleth ShibRequestSetting requireSession 1
ShibRequestSetting requireSession 1 ShibUseHeaders On
ShibUseHeaders On require valid-user
require valid-user </Location>
</Location>
Alias /shibboleth-sp /usr/share/shibboleth
Alias /shibboleth-sp /usr/share/shibboleth <Location /shibboleth-sp>
<Location /shibboleth-sp> Satisfy any
Satisfy any </Location>
</Location>
<Location /Shibboleth.sso>
<Location /Shibboleth.sso> SetHandler shib
SetHandler shib </Location>
</Location> ```
```
exclude shibboleth URLs from rewriting, add "RewriteCond %{REQUEST_URI} !/Shibboleth.sso" and "RewriteCond %{REQUEST_URI} !/shibboleth-sp", config should look like this: 1. Exclude shibboleth URLs from rewriting. Add `RewriteCond %{REQUEST_URI} !/Shibboleth.sso` and `RewriteCond %{REQUEST_URI} !/shibboleth-sp`. Config should look like this:
```
# Apache equivalent of Nginx try files ```
RewriteEngine on # Apache equivalent of Nginx try files
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteEngine on
RewriteCond %{REQUEST_URI} !/Shibboleth.sso RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/shibboleth-sp RewriteCond %{REQUEST_URI} !/Shibboleth.sso
RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA] RewriteCond %{REQUEST_URI} !/shibboleth-sp
RequestHeader set X_FORWARDED_PROTO 'https' RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]
``` RequestHeader set X_FORWARDED_PROTO 'https'
```
1. Edit /etc/gitlab/gitlab.rb configuration file to enable OmniAuth and add
Shibboleth as an OmniAuth provider. User attributes will be sent from the 1. Edit `/etc/gitlab/gitlab.rb` configuration file to enable OmniAuth and add
Apache reverse proxy to GitLab as headers with the names from the Shibboleth Shibboleth as an OmniAuth provider. User attributes will be sent from the
attribute mapping. Therefore the values of the `args` hash Apache reverse proxy to GitLab as headers with the names from the Shibboleth
should be in the form of `"HTTP_ATTRIBUTE"`. The keys in the hash are arguments attribute mapping. Therefore the values of the `args` hash
to the [OmniAuth::Strategies::Shibboleth class](https://github.com/toyokazu/omniauth-shibboleth/blob/master/lib/omniauth/strategies/shibboleth.rb) should be in the form of `"HTTP_ATTRIBUTE"`. The keys in the hash are arguments
and are documented by the [omniauth-shibboleth gem](https://github.com/toyokazu/omniauth-shibboleth) to the [OmniAuth::Strategies::Shibboleth class](https://github.com/toyokazu/omniauth-shibboleth/blob/master/lib/omniauth/strategies/shibboleth.rb)
(take care to note the version of the gem packaged with GitLab). If some of and are documented by the [omniauth-shibboleth gem](https://github.com/toyokazu/omniauth-shibboleth)
your users appear to be authenticated by Shibboleth and Apache, but GitLab (take care to note the version of the gem packaged with GitLab). If some of
rejects their account with a URI that contains "e-mail is invalid" then your your users appear to be authenticated by Shibboleth and Apache, but GitLab
Shibboleth Identity Provider or Attribute Authority may be asserting multiple rejects their account with a URI that contains "e-mail is invalid" then your
e-mail addresses. In this instance, you might consider setting the Shibboleth Identity Provider or Attribute Authority may be asserting multiple
`multi_values` argument to `first`. e-mail addresses. In this instance, you might consider setting the
`multi_values` argument to `first`.
File should look like this:
``` The file should look like this:
external_url 'https://gitlab.example.com'
gitlab_rails['internal_api_url'] = 'https://gitlab.example.com' ```
external_url 'https://gitlab.example.com'
# disable Nginx gitlab_rails['internal_api_url'] = 'https://gitlab.example.com'
nginx['enable'] = false
# disable Nginx
gitlab_rails['omniauth_allow_single_sign_on'] = true nginx['enable'] = false
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_enabled'] = true gitlab_rails['omniauth_allow_single_sign_on'] = true
gitlab_rails['omniauth_providers'] = [ gitlab_rails['omniauth_block_auto_created_users'] = false
{ gitlab_rails['omniauth_enabled'] = true
"name" => "'shibboleth"', gitlab_rails['omniauth_providers'] = [
"label" => "Text for Login Button", {
"args" => { "name" => "'shibboleth"',
"shib_session_id_field" => "HTTP_SHIB_SESSION_ID", "label" => "Text for Login Button",
"shib_application_id_field" => "HTTP_SHIB_APPLICATION_ID", "args" => {
"uid_field" => 'HTTP_EPPN', "shib_session_id_field" => "HTTP_SHIB_SESSION_ID",
"name_field" => 'HTTP_CN', "shib_application_id_field" => "HTTP_SHIB_APPLICATION_ID",
"info_fields" => { "email" => 'HTTP_MAIL'} "uid_field" => 'HTTP_EPPN',
} "name_field" => 'HTTP_CN',
} "info_fields" => { "email" => 'HTTP_MAIL'}
] }
}
``` ]
1. [Reconfigure][] or [restart GitLab][] for the changes to take effect if you ```
1. [Reconfigure](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure) or [restart](../administration/restart_gitlab.md#installations-from-source) GitLab for the changes to take effect if you
installed GitLab via Omnibus or from source respectively. installed GitLab via Omnibus or from source respectively.
On the sign in page there should now be a "Sign in with: Shibboleth" icon below the regular sign in form. Click the icon to begin the authentication process. You will be redirected to IdP server (Depends on your Shibboleth module configuration). If everything goes well the user will be returned to GitLab and will be signed in. On the sign in page, there should now be a "Sign in with: Shibboleth" icon below the regular sign in form. Click the icon to begin the authentication process. You will be redirected to IdP server (depends on your Shibboleth module configuration). If everything goes well the user will be returned to GitLab and will be signed in.
## Apache 2.4 / GitLab 8.6 update ## Apache 2.4 / GitLab 8.6 update
The order of the first 2 Location directives is important. If they are reversed, The order of the first 2 Location directives is important. If they are reversed,
you will not get a shibboleth session! you will not get a shibboleth session!
...@@ -135,6 +138,3 @@ you will not get a shibboleth session! ...@@ -135,6 +138,3 @@ you will not get a shibboleth session!
RequestHeader set X_FORWARDED_PROTO 'https' RequestHeader set X_FORWARDED_PROTO 'https'
RequestHeader set X-Forwarded-Ssl on RequestHeader set X-Forwarded-Ssl on
``` ```
[reconfigure]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure
[restart GitLab]: ../administration/restart_gitlab.md#installations-from-source
...@@ -20,7 +20,7 @@ database migrations for GitLab 7.2. ...@@ -20,7 +20,7 @@ database migrations for GitLab 7.2.
## Stash changes ## Stash changes
If you [deleted the vendors folder during your original installation](https://github.com/gitlabhq/gitlabhq/issues/4883#issuecomment-31108431), [you will get an error](https://gitlab.com/gitlab-org/gitlab-ce/issues/1494) when you attempt to rebuild the assets in step 7. To avoid this, stash the changes in your GitLab working copy before starting: If you deleted the vendors folder during your original installation, [you will get an error](https://gitlab.com/gitlab-org/gitlab-ce/issues/1494) when you attempt to rebuild the assets in step 7. To avoid this, stash the changes in your GitLab working copy before starting:
git stash git stash
......
# Discord Notifications service # Discord Notifications service
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22684) in GitLab 11.5. > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22684) in GitLab 11.6.
The Discord Notifications service sends event notifications from GitLab to the channel for which the webhook was created. The Discord Notifications service sends event notifications from GitLab to the channel for which the webhook was created.
......
...@@ -10,7 +10,7 @@ module Gitlab ...@@ -10,7 +10,7 @@ module Gitlab
image: 'illustrations/illustrations_scheduled-job_countdown.svg', image: 'illustrations/illustrations_scheduled-job_countdown.svg',
size: 'svg-394', size: 'svg-394',
title: _("This is a delayed job to run in %{remainingTime}"), title: _("This is a delayed job to run in %{remainingTime}"),
content: _("This job will automatically run after it's timer finishes. " \ content: _("This job will automatically run after its timer finishes. " \
"Often they are used for incremental roll-out deploys " \ "Often they are used for incremental roll-out deploys " \
"to production environments. When unscheduled it converts " \ "to production environments. When unscheduled it converts " \
"into a manual action.") "into a manual action.")
......
# frozen_string_literal: true # frozen_string_literal: true
# Gitaly note: JV: seems to be completely migrated (behind feature flags).
module Gitlab module Gitlab
module Git module Git
class Blob class Blob
......
...@@ -885,12 +885,6 @@ module Gitlab ...@@ -885,12 +885,6 @@ module Gitlab
Gitlab::GitalyClient::ConflictsService.new(self, our_commit_oid, their_commit_oid) Gitlab::GitalyClient::ConflictsService.new(self, our_commit_oid, their_commit_oid)
end end
def gitaly_migrate(method, status: Gitlab::GitalyClient::MigrationStatus::OPT_IN, &block)
wrapped_gitaly_errors do
Gitlab::GitalyClient.migrate(method, status: status, &block)
end
end
def clean_stale_repository_files def clean_stale_repository_files
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_repository_client.cleanup if exists? gitaly_repository_client.cleanup if exists?
......
...@@ -9,11 +9,6 @@ require 'grpc/health/v1/health_services_pb' ...@@ -9,11 +9,6 @@ require 'grpc/health/v1/health_services_pb'
module Gitlab module Gitlab
module GitalyClient module GitalyClient
include Gitlab::Metrics::Methods include Gitlab::Metrics::Methods
module MigrationStatus
DISABLED = 1
OPT_IN = 2
OPT_OUT = 3
end
class TooManyInvocationsError < StandardError class TooManyInvocationsError < StandardError
attr_reader :call_site, :invocation_count, :max_call_stack attr_reader :call_site, :invocation_count, :max_call_stack
...@@ -31,7 +26,7 @@ module Gitlab ...@@ -31,7 +26,7 @@ module Gitlab
end end
end end
SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'.freeze SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'
MAXIMUM_GITALY_CALLS = 35 MAXIMUM_GITALY_CALLS = 35
CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze
...@@ -43,11 +38,6 @@ module Gitlab ...@@ -43,11 +38,6 @@ module Gitlab
self.query_time = 0 self.query_time = 0
define_histogram :gitaly_migrate_call_duration_seconds do
docstring "Gitaly migration call execution timings"
base_labels gitaly_enabled: nil, feature: nil
end
define_histogram :gitaly_controller_action_duration_seconds do define_histogram :gitaly_controller_action_duration_seconds do
docstring "Gitaly endpoint histogram by controller and action combination" docstring "Gitaly endpoint histogram by controller and action combination"
base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil) base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil)
...@@ -126,7 +116,6 @@ module Gitlab ...@@ -126,7 +116,6 @@ module Gitlab
def self.call(storage, service, rpc, request, remote_storage: nil, timeout: nil) def self.call(storage, service, rpc, request, remote_storage: nil, timeout: nil)
start = Gitlab::Metrics::System.monotonic_time start = Gitlab::Metrics::System.monotonic_time
request_hash = request.is_a?(Google::Protobuf::MessageExts) ? request.to_h : {} request_hash = request.is_a?(Google::Protobuf::MessageExts) ? request.to_h : {}
@current_call_id ||= SecureRandom.uuid
enforce_gitaly_request_limits(:call) enforce_gitaly_request_limits(:call)
...@@ -145,9 +134,7 @@ module Gitlab ...@@ -145,9 +134,7 @@ module Gitlab
current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s), current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s),
duration) duration)
add_call_details(id: @current_call_id, feature: service, duration: duration, request: request_hash) add_call_details(feature: "#{service}##{rpc}", duration: duration, request: request_hash, rpc: rpc)
@current_call_id = nil
end end
def self.handle_grpc_unavailable!(ex) def self.handle_grpc_unavailable!(ex)
...@@ -222,7 +209,7 @@ module Gitlab ...@@ -222,7 +209,7 @@ module Gitlab
result result
end end
SERVER_FEATURE_FLAGS = %w[gogit_findcommit].freeze SERVER_FEATURE_FLAGS = %w[].freeze
def self.server_feature_flags def self.server_feature_flags
SERVER_FEATURE_FLAGS.map do |f| SERVER_FEATURE_FLAGS.map do |f|
...@@ -237,82 +224,8 @@ module Gitlab ...@@ -237,82 +224,8 @@ module Gitlab
params['gitaly_token'].presence || Gitlab.config.gitaly['token'] params['gitaly_token'].presence || Gitlab.config.gitaly['token']
end end
# Evaluates whether a feature toggle is on or off def self.feature_enabled?(feature_name)
def self.feature_enabled?(feature_name, status: MigrationStatus::OPT_IN) Feature.enabled?("gitaly_#{feature_name}")
# Disabled features are always off!
return false if status == MigrationStatus::DISABLED
feature = Feature.get("gitaly_#{feature_name}")
# If the feature has been set, always evaluate
if Feature.persisted?(feature)
if feature.percentage_of_time_value > 0
# Probabilistically enable this feature
return Random.rand() * 100 < feature.percentage_of_time_value
end
return feature.enabled?
end
# If the feature has not been set, the default depends
# on it's status
case status
when MigrationStatus::OPT_OUT
true
when MigrationStatus::OPT_IN
opt_into_all_features? && !explicit_opt_in_required.include?(feature_name)
else
false
end
rescue => ex
# During application startup feature lookups in SQL can fail
Rails.logger.warn "exception while checking Gitaly feature status for #{feature_name}: #{ex}"
false
end
# We have a mechanism to let GitLab automatically opt in to all Gitaly
# features. We want to be able to exclude some features from automatic
# opt-in. This function has an override in EE.
def self.explicit_opt_in_required
[]
end
# opt_into_all_features? returns true when the current environment
# is one in which we opt into features automatically
def self.opt_into_all_features?
Rails.env.development? || ENV["GITALY_FEATURE_DEFAULT_ON"] == "1"
end
private_class_method :opt_into_all_features?
def self.migrate(feature, status: MigrationStatus::OPT_IN)
# Enforce limits at both the `migrate` and `call` sites to ensure that
# problems are not hidden by a feature being disabled
enforce_gitaly_request_limits(:migrate)
is_enabled = feature_enabled?(feature, status: status)
metric_name = feature.to_s
metric_name += "_gitaly" if is_enabled
Gitlab::Metrics.measure(metric_name) do
# Some migrate calls wrap other migrate calls
allow_n_plus_1_calls do
feature_stack = Thread.current[:gitaly_feature_stack] ||= []
feature_stack.unshift(feature)
begin
start = Gitlab::Metrics::System.monotonic_time
@current_call_id = SecureRandom.uuid
call_details = { id: @current_call_id }
yield is_enabled
ensure
total_time = Gitlab::Metrics::System.monotonic_time - start
gitaly_migrate_call_duration_seconds.observe({ gitaly_enabled: is_enabled, feature: feature }, total_time)
feature_stack.shift
Thread.current[:gitaly_feature_stack] = nil if feature_stack.empty?
add_call_details(call_details.merge(feature: feature, duration: total_time))
end
end
end
end end
# Ensures that Gitaly is not being abuse through n+1 misuse etc # Ensures that Gitaly is not being abuse through n+1 misuse etc
...@@ -368,48 +281,29 @@ module Gitlab ...@@ -368,48 +281,29 @@ module Gitlab
end end
private_class_method :decrement_call_count private_class_method :decrement_call_count
# Returns an estimate of the number of Gitaly calls made for this # Returns the of the number of Gitaly calls made for this request
# request
def self.get_request_count def self.get_request_count
return 0 unless Gitlab::SafeRequestStore.active? get_call_count("gitaly_call_actual")
gitaly_migrate_count = get_call_count("gitaly_migrate_actual")
gitaly_call_count = get_call_count("gitaly_call_actual")
# Using the maximum of migrate and call_count will provide an
# indicator of how many Gitaly calls will be made, even
# before a feature is enabled. This provides us with a single
# metric, but not an exact number, but this tradeoff is acceptable
if gitaly_migrate_count > gitaly_call_count
gitaly_migrate_count
else
gitaly_call_count
end
end end
def self.reset_counts def self.reset_counts
return unless Gitlab::SafeRequestStore.active? return unless Gitlab::SafeRequestStore.active?
%w[migrate call].each do |call_site| Gitlab::SafeRequestStore["gitaly_call_actual"] = 0
Gitlab::SafeRequestStore["gitaly_#{call_site}_actual"] = 0 Gitlab::SafeRequestStore["gitaly_call_permitted"] = 0
Gitlab::SafeRequestStore["gitaly_#{call_site}_permitted"] = 0
end
end end
def self.add_call_details(details) def self.add_call_details(details)
id = details.delete(:id) return unless Gitlab::SafeRequestStore[:peek_enabled]
return unless id && Gitlab::SafeRequestStore[:peek_enabled]
Gitlab::SafeRequestStore['gitaly_call_details'] ||= {} Gitlab::SafeRequestStore['gitaly_call_details'] ||= []
Gitlab::SafeRequestStore['gitaly_call_details'][id] ||= {} Gitlab::SafeRequestStore['gitaly_call_details'] << details
Gitlab::SafeRequestStore['gitaly_call_details'][id].merge!(details)
end end
def self.list_call_details def self.list_call_details
return {} unless Gitlab::SafeRequestStore[:peek_enabled] return [] unless Gitlab::SafeRequestStore[:peek_enabled]
Gitlab::SafeRequestStore['gitaly_call_details'] || {} Gitlab::SafeRequestStore['gitaly_call_details'] || []
end end
def self.expected_server_version def self.expected_server_version
......
...@@ -23,7 +23,6 @@ module Peek ...@@ -23,7 +23,6 @@ module Peek
def details def details
::Gitlab::GitalyClient.list_call_details ::Gitlab::GitalyClient.list_call_details
.values
.sort { |a, b| b[:duration] <=> a[:duration] } .sort { |a, b| b[:duration] <=> a[:duration] }
.map(&method(:format_call_details)) .map(&method(:format_call_details))
end end
......
...@@ -7,7 +7,7 @@ module SystemCheck ...@@ -7,7 +7,7 @@ module SystemCheck
set_check_pass -> { "yes (#{self.current_version})" } set_check_pass -> { "yes (#{self.current_version})" }
def self.required_version def self.required_version
@required_version ||= Gitlab::VersionInfo.new(2, 9, 5) @required_version ||= Gitlab::VersionInfo.parse('2.18.0')
end end
def self.current_version def self.current_version
......
...@@ -11,7 +11,7 @@ module SystemCheck ...@@ -11,7 +11,7 @@ module SystemCheck
end end
def self.current_version def self.current_version
@current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%w(ruby --version))) @current_version ||= Gitlab::VersionInfo.parse(RUBY_VERSION)
end end
def check? def check?
......
...@@ -599,34 +599,7 @@ msgstr "" ...@@ -599,34 +599,7 @@ msgstr ""
msgid "An error has occurred" msgid "An error has occurred"
msgstr "" msgstr ""
msgid "An error occured creating the new branch." msgid "An error occurred creating the new branch."
msgstr ""
msgid "An error occured whilst fetching the job trace."
msgstr ""
msgid "An error occured whilst fetching the latest pipeline."
msgstr ""
msgid "An error occured whilst loading all the files."
msgstr ""
msgid "An error occured whilst loading the file content."
msgstr ""
msgid "An error occured whilst loading the file."
msgstr ""
msgid "An error occured whilst loading the merge request changes."
msgstr ""
msgid "An error occured whilst loading the merge request version data."
msgstr ""
msgid "An error occured whilst loading the merge request."
msgstr ""
msgid "An error occured whilst loading the pipelines jobs."
msgstr "" msgstr ""
msgid "An error occurred adding a draft to the discussion." msgid "An error occurred adding a draft to the discussion."
...@@ -743,6 +716,33 @@ msgstr "" ...@@ -743,6 +716,33 @@ msgstr ""
msgid "An error occurred while validating username" msgid "An error occurred while validating username"
msgstr "" msgstr ""
msgid "An error occurred whilst fetching the job trace."
msgstr ""
msgid "An error occurred whilst fetching the latest pipeline."
msgstr ""
msgid "An error occurred whilst loading all the files."
msgstr ""
msgid "An error occurred whilst loading the file content."
msgstr ""
msgid "An error occurred whilst loading the file."
msgstr ""
msgid "An error occurred whilst loading the merge request changes."
msgstr ""
msgid "An error occurred whilst loading the merge request version data."
msgstr ""
msgid "An error occurred whilst loading the merge request."
msgstr ""
msgid "An error occurred whilst loading the pipelines jobs."
msgstr ""
msgid "An error occurred. Please try again." msgid "An error occurred. Please try again."
msgstr "" msgstr ""
...@@ -1597,10 +1597,14 @@ msgstr "" ...@@ -1597,10 +1597,14 @@ msgstr ""
msgid "CiVariable|All environments" msgid "CiVariable|All environments"
msgstr "" msgstr ""
<<<<<<< HEAD
msgid "CiVariable|Create wildcard" msgid "CiVariable|Create wildcard"
msgstr "" msgstr ""
msgid "CiVariable|Error occured while saving variables" msgid "CiVariable|Error occured while saving variables"
=======
msgid "CiVariable|Error occurred while saving variables"
>>>>>>> upstream/master
msgstr "" msgstr ""
msgid "CiVariable|New environment" msgid "CiVariable|New environment"
...@@ -1708,13 +1712,13 @@ msgstr "" ...@@ -1708,13 +1712,13 @@ msgstr ""
msgid "ClusterIntegration|An error occured while trying to fetch project zones: %{error}" msgid "ClusterIntegration|An error occured while trying to fetch project zones: %{error}"
msgstr "" msgstr ""
msgid "ClusterIntegration|An error occured while trying to fetch your projects: %{error}" msgid "ClusterIntegration|An error occurred when trying to contact the Google Cloud API. Please try again later."
msgstr "" msgstr ""
msgid "ClusterIntegration|An error occured while trying to fetch zone machine types: %{error}" msgid "ClusterIntegration|An error occurred while trying to fetch your projects: %{error}"
msgstr "" msgstr ""
msgid "ClusterIntegration|An error occurred when trying to contact the Google Cloud API. Please try again later." msgid "ClusterIntegration|An error occurred while trying to fetch zone machine types: %{error}"
msgstr "" msgstr ""
msgid "ClusterIntegration|Applications" msgid "ClusterIntegration|Applications"
...@@ -8289,7 +8293,7 @@ msgstr "" ...@@ -8289,7 +8293,7 @@ msgstr ""
msgid "This job requires a manual action" msgid "This job requires a manual action"
msgstr "" msgstr ""
msgid "This job will automatically run after it's timer finishes. Often they are used for incremental roll-out deploys to production environments. When unscheduled it converts into a manual action." msgid "This job will automatically run after its timer finishes. Often they are used for incremental roll-out deploys to production environments. When unscheduled it converts into a manual action."
msgstr "" msgstr ""
msgid "This means you can not push code until you create an empty repository or import existing one." msgid "This means you can not push code until you create an empty repository or import existing one."
......
...@@ -56,7 +56,7 @@ GEM ...@@ -56,7 +56,7 @@ GEM
byebug (~> 9.1) byebug (~> 9.1)
pry (~> 0.10) pry (~> 0.10)
public_suffix (3.0.1) public_suffix (3.0.1)
rack (2.0.3) rack (2.0.6)
rack-test (0.8.2) rack-test (0.8.2)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rake (12.3.0) rake (12.3.0)
...@@ -103,4 +103,4 @@ DEPENDENCIES ...@@ -103,4 +103,4 @@ DEPENDENCIES
selenium-webdriver (~> 3.8.0) selenium-webdriver (~> 3.8.0)
BUNDLED WITH BUNDLED WITH
1.16.4 1.17.1
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
rack (2.0.4) rack (2.0.6)
rake (12.3.0) rake (12.3.0)
PLATFORMS PLATFORMS
...@@ -12,4 +12,4 @@ DEPENDENCIES ...@@ -12,4 +12,4 @@ DEPENDENCIES
rake rake
BUNDLED WITH BUNDLED WITH
1.16.1 1.17.1
# frozen_string_literal: true
module RuboCop
module Cop
class SafeParams < RuboCop::Cop::Cop
MSG = 'Use `safe_params` instead of `params` in url_for.'.freeze
METHOD_NAME_PATTERN = :url_for
UNSAFE_PARAM = :params
def on_send(node)
return unless method_name(node) == METHOD_NAME_PATTERN
add_offense(node, location: :expression) unless safe_params?(node)
end
private
def safe_params?(node)
node.descendants.each do |param_node|
next unless param_node.descendants.empty?
return false if method_name(param_node) == UNSAFE_PARAM
end
true
end
def method_name(node)
node.children[1]
end
end
end
end
...@@ -5,6 +5,7 @@ require_relative 'cop/gitlab/httparty' ...@@ -5,6 +5,7 @@ require_relative 'cop/gitlab/httparty'
require_relative 'cop/gitlab/finder_with_find_by' require_relative 'cop/gitlab/finder_with_find_by'
require_relative 'cop/gitlab/union' require_relative 'cop/gitlab/union'
require_relative 'cop/include_sidekiq_worker' require_relative 'cop/include_sidekiq_worker'
require_relative 'cop/safe_params'
require_relative 'cop/avoid_return_from_blocks' require_relative 'cop/avoid_return_from_blocks'
require_relative 'cop/avoid_break_from_strong_memoize' require_relative 'cop/avoid_break_from_strong_memoize'
require_relative 'cop/avoid_route_redirect_leading_slash' require_relative 'cop/avoid_route_redirect_leading_slash'
......
...@@ -111,6 +111,6 @@ Promise.all(matchedFiles.map(checkFileWithPrettierConfig)) ...@@ -111,6 +111,6 @@ Promise.all(matchedFiles.map(checkFileWithPrettierConfig))
if (didWarn) process.exit(1); if (didWarn) process.exit(1);
}) })
.catch(e => { .catch(e => {
console.log(`\nAn error occured while processing files with prettier: ${e.message}\n`); console.log(`\nAn error occurred while processing files with prettier: ${e.message}\n`);
process.exit(1); process.exit(1);
}); });
...@@ -106,6 +106,7 @@ module Trigger ...@@ -106,6 +106,7 @@ module Trigger
def extra_variables def extra_variables
{ {
'GITLAB_VERSION' => ENV['CI_COMMIT_SHA'], 'GITLAB_VERSION' => ENV['CI_COMMIT_SHA'],
'GITLAB_REF_SLUG' => ENV['CI_COMMIT_REF_SLUG'],
'ALTERNATIVE_SOURCES' => 'true', 'ALTERNATIVE_SOURCES' => 'true',
'ee' => Trigger.ee? ? 'true' : 'false', 'ee' => Trigger.ee? ? 'true' : 'false',
'QA_BRANCH' => ENV['QA_BRANCH'] || 'master' 'QA_BRANCH' => ENV['QA_BRANCH'] || 'master'
......
...@@ -596,7 +596,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do ...@@ -596,7 +596,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
it 'shows delayed job', :js do it 'shows delayed job', :js do
expect(page).to have_content('This is a delayed job to run in') expect(page).to have_content('This is a delayed job to run in')
expect(page).to have_content("This job will automatically run after it's timer finishes.") expect(page).to have_content("This job will automatically run after its timer finishes.")
expect(page).to have_link('Unschedule job') expect(page).to have_link('Unschedule job')
end end
......
require 'spec_helper' require 'spec_helper'
describe 'User views a wiki page' do describe 'User views a wiki page' do
shared_examples 'wiki page user view' do include WikiHelpers
include WikiHelpers
let(:user) { create(:user) }
let(:user) { create(:user) } let(:project) { create(:project, :wiki_repo, namespace: user.namespace) }
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) } let(:path) { 'image.png' }
let(:path) { 'image.png' } let(:wiki_page) do
let(:wiki_page) do create(:wiki_page,
create(:wiki_page, wiki: project.wiki,
wiki: project.wiki, attrs: { title: 'home', content: "Look at this [image](#{path})\n\n ![alt text](#{path})" })
attrs: { title: 'home', content: "Look at this [image](#{path})\n\n ![alt text](#{path})" }) end
end
before do before do
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
end end
context 'when wiki is empty' do context 'when wiki is empty' do
before do before do
visit(project_wikis_path(project)) visit(project_wikis_path(project))
click_link "Create your first page" click_link "Create your first page"
click_on('New page') click_on('New page')
page.within('#modal-new-wiki') do page.within('#modal-new-wiki') do
fill_in(:new_wiki_path, with: 'one/two/three-test') fill_in(:new_wiki_path, with: 'one/two/three-test')
click_on('Create page') click_on('Create page')
end end
page.within('.wiki-form') do page.within('.wiki-form') do
fill_in(:wiki_content, with: 'wiki content') fill_in(:wiki_content, with: 'wiki content')
click_on('Create page') click_on('Create page')
end
end end
end
it 'shows the history of a page that has a path', :js do it 'shows the history of a page that has a path', :js do
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
first(:link, text: 'Three').click first(:link, text: 'Three').click
click_on('Page history') click_on('Page history')
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
page.within(:css, '.nav-text') do page.within(:css, '.nav-text') do
expect(page).to have_content('History') expect(page).to have_content('History')
end
end end
end
it 'shows an old version of a page', :js do it 'shows an old version of a page', :js do
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
expect(find('.wiki-pages')).to have_content('Three') expect(find('.wiki-pages')).to have_content('Three')
first(:link, text: 'Three').click
expect(find('.nav-text')).to have_content('Three')
click_on('Edit') first(:link, text: 'Three').click
expect(current_path).to include('one/two/three-test') expect(find('.nav-text')).to have_content('Three')
expect(page).to have_content('Edit Page')
fill_in('Content', with: 'Updated Wiki Content') click_on('Edit')
click_on('Save changes') expect(current_path).to include('one/two/three-test')
click_on('Page history') expect(page).to have_content('Edit Page')
page.within(:css, '.nav-text') do fill_in('Content', with: 'Updated Wiki Content')
expect(page).to have_content('History')
end
find('a[href*="?version_id"]') click_on('Save changes')
end click_on('Page history')
end
context 'when a page does not have history' do
before do
visit(project_wiki_path(project, wiki_page))
end
it 'shows all the pages' do page.within(:css, '.nav-text') do
expect(page).to have_content(user.name) expect(page).to have_content('History')
expect(find('.wiki-pages')).to have_content(wiki_page.title.capitalize)
end end
context 'shows a file stored in a page' do find('a[href*="?version_id"]')
let(:path) { upload_file_to_wiki(project, user, 'dk.png') } end
end
it do context 'when a page does not have history' do
expect(page).to have_xpath("//img[@data-src='#{project.wiki.wiki_base_path}/#{path}']") before do
expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}") visit(project_wiki_path(project, wiki_page))
end
click_on('image') it 'shows all the pages' do
expect(page).to have_content(user.name)
expect(find('.wiki-pages')).to have_content(wiki_page.title.capitalize)
end
expect(current_path).to match("wikis/#{path}") context 'shows a file stored in a page' do
expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved let(:path) { upload_file_to_wiki(project, user, 'dk.png') }
end
end
it 'shows the creation page if file does not exist' do it do
expect(page).to have_xpath("//img[@data-src='#{project.wiki.wiki_base_path}/#{path}']")
expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}") expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}")
click_on('image') click_on('image')
expect(current_path).to match("wikis/#{path}") expect(current_path).to match("wikis/#{path}")
expect(page).to have_content('New Wiki Page') expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved
expect(page).to have_content('Create page')
end end
end end
context 'when a page has history' do it 'shows the creation page if file does not exist' do
before do expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}")
wiki_page.update(message: 'updated home', content: 'updated [some link](other-page)')
end
it 'shows the page history' do click_on('image')
visit(project_wiki_path(project, wiki_page))
expect(page).to have_selector('a.btn', text: 'Edit') expect(current_path).to match("wikis/#{path}")
expect(page).to have_content('New Wiki Page')
expect(page).to have_content('Create page')
end
end
click_on('Page history') context 'when a page has history' do
before do
wiki_page.update(message: 'updated home', content: 'updated [some link](other-page)')
end
expect(page).to have_content(user.name) it 'shows the page history' do
expect(page).to have_content("#{user.username} created page: home") visit(project_wiki_path(project, wiki_page))
expect(page).to have_content('updated home')
end
it 'does not show the "Edit" button' do expect(page).to have_selector('a.btn', text: 'Edit')
visit(project_wiki_path(project, wiki_page, version_id: wiki_page.versions.last.id))
expect(page).not_to have_selector('a.btn', text: 'Edit') click_on('Page history')
end
expect(page).to have_content(user.name)
expect(page).to have_content("#{user.username} created page: home")
expect(page).to have_content('updated home')
end end
context 'when page has invalid content encoding' do it 'does not show the "Edit" button' do
let(:content) { 'whatever'.force_encoding('ISO-8859-1') } visit(project_wiki_path(project, wiki_page, version_id: wiki_page.versions.last.id))
before do expect(page).not_to have_selector('a.btn', text: 'Edit')
allow(Gitlab::EncodingHelper).to receive(:encode!).and_return(content) end
end
visit(project_wiki_path(project, wiki_page)) context 'when page has invalid content encoding' do
end let(:content) { 'whatever'.force_encoding('ISO-8859-1') }
it 'does not show "Edit" button' do before do
expect(page).not_to have_selector('a.btn', text: 'Edit') allow(Gitlab::EncodingHelper).to receive(:encode!).and_return(content)
end
it 'shows error' do visit(project_wiki_path(project, wiki_page))
page.within(:css, '.flash-notice') do
expect(page).to have_content('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.')
end
end
end end
it 'opens a default wiki page', :js do it 'does not show "Edit" button' do
visit(project_path(project)) expect(page).not_to have_selector('a.btn', text: 'Edit')
end
find('.shortcuts-wiki').click
click_link "Create your first page"
expect(page).to have_content('Home · Create Page') it 'shows error' do
page.within(:css, '.flash-notice') do
expect(page).to have_content('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.')
end
end end
end end
context 'when Gitaly is enabled' do it 'opens a default wiki page', :js do
it_behaves_like 'wiki page user view' visit(project_path(project))
end
find('.shortcuts-wiki').click
click_link "Create your first page"
context 'when Gitaly is disabled', :skip_gitaly_mock do expect(page).to have_content('Home · Create Page')
it_behaves_like 'wiki page user view'
end end
end end
...@@ -296,7 +296,7 @@ describe('IDE store file actions', () => { ...@@ -296,7 +296,7 @@ describe('IDE store file actions', () => {
.getFileData({ state: store.state, commit() {}, dispatch }, { path: localFile.path }) .getFileData({ state: store.state, commit() {}, dispatch }, { path: localFile.path })
.then(() => { .then(() => {
expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { expect(dispatch).toHaveBeenCalledWith('setErrorMessage', {
text: 'An error occured whilst loading the file.', text: 'An error occurred whilst loading the file.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { actionPayload: {
...@@ -408,7 +408,7 @@ describe('IDE store file actions', () => { ...@@ -408,7 +408,7 @@ describe('IDE store file actions', () => {
.then(done.fail) .then(done.fail)
.catch(() => { .catch(() => {
expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { expect(dispatch).toHaveBeenCalledWith('setErrorMessage', {
text: 'An error occured whilst loading the file content.', text: 'An error occurred whilst loading the file content.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { actionPayload: {
......
...@@ -82,7 +82,7 @@ describe('IDE store merge request actions', () => { ...@@ -82,7 +82,7 @@ describe('IDE store merge request actions', () => {
.then(done.fail) .then(done.fail)
.catch(() => { .catch(() => {
expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { expect(dispatch).toHaveBeenCalledWith('setErrorMessage', {
text: 'An error occured whilst loading the merge request.', text: 'An error occurred whilst loading the merge request.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { actionPayload: {
...@@ -155,7 +155,7 @@ describe('IDE store merge request actions', () => { ...@@ -155,7 +155,7 @@ describe('IDE store merge request actions', () => {
.then(done.fail) .then(done.fail)
.catch(() => { .catch(() => {
expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { expect(dispatch).toHaveBeenCalledWith('setErrorMessage', {
text: 'An error occured whilst loading the merge request changes.', text: 'An error occurred whilst loading the merge request changes.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { actionPayload: {
...@@ -225,7 +225,7 @@ describe('IDE store merge request actions', () => { ...@@ -225,7 +225,7 @@ describe('IDE store merge request actions', () => {
.then(done.fail) .then(done.fail)
.catch(() => { .catch(() => {
expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { expect(dispatch).toHaveBeenCalledWith('setErrorMessage', {
text: 'An error occured whilst loading the merge request version data.', text: 'An error occurred whilst loading the merge request version data.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { actionPayload: {
......
...@@ -143,7 +143,7 @@ describe('Multi-file store tree actions', () => { ...@@ -143,7 +143,7 @@ describe('Multi-file store tree actions', () => {
.then(done.fail) .then(done.fail)
.catch(() => { .catch(() => {
expect(dispatch).toHaveBeenCalledWith('setErrorMessage', { expect(dispatch).toHaveBeenCalledWith('setErrorMessage', {
text: 'An error occured whilst loading all the files.', text: 'An error occurred whilst loading all the files.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { projectId: 'abc/def', branchId: 'master-testing' }, actionPayload: { projectId: 'abc/def', branchId: 'master-testing' },
......
...@@ -77,7 +77,7 @@ describe('IDE pipelines actions', () => { ...@@ -77,7 +77,7 @@ describe('IDE pipelines actions', () => {
{ {
type: 'setErrorMessage', type: 'setErrorMessage',
payload: { payload: {
text: 'An error occured whilst fetching the latest pipeline.', text: 'An error occurred whilst fetching the latest pipeline.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: null, actionPayload: null,
...@@ -223,7 +223,7 @@ describe('IDE pipelines actions', () => { ...@@ -223,7 +223,7 @@ describe('IDE pipelines actions', () => {
{ {
type: 'setErrorMessage', type: 'setErrorMessage',
payload: { payload: {
text: 'An error occured whilst loading the pipelines jobs.', text: 'An error occurred whilst loading the pipelines jobs.',
action: jasmine.anything(), action: jasmine.anything(),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { id: 1 }, actionPayload: { id: 1 },
...@@ -360,7 +360,7 @@ describe('IDE pipelines actions', () => { ...@@ -360,7 +360,7 @@ describe('IDE pipelines actions', () => {
{ {
type: 'setErrorMessage', type: 'setErrorMessage',
payload: { payload: {
text: 'An error occured whilst fetching the job trace.', text: 'An error occurred whilst fetching the job trace.',
action: jasmine.any(Function), action: jasmine.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: null, actionPayload: null,
......
...@@ -205,28 +205,18 @@ describe ExtractsPath do ...@@ -205,28 +205,18 @@ describe ExtractsPath do
end end
describe '#lfs_blob_ids' do describe '#lfs_blob_ids' do
shared_examples '#lfs_blob_ids' do let(:tag) { @project.repository.add_tag(@project.owner, 'my-annotated-tag', 'master', 'test tag') }
let(:tag) { @project.repository.add_tag(@project.owner, 'my-annotated-tag', 'master', 'test tag') } let(:ref) { tag.target }
let(:ref) { tag.target } let(:params) { { ref: ref, path: 'README.md' } }
let(:params) { { ref: ref, path: 'README.md' } }
before do before do
@project = create(:project, :repository) @project = create(:project, :repository)
end
it 'handles annotated tags' do
assign_ref_vars
expect(lfs_blob_ids).to eq([])
end
end end
context 'when gitaly is enabled' do it 'handles annotated tags' do
it_behaves_like '#lfs_blob_ids' assign_ref_vars
end
context 'when gitaly is disabled', :skip_gitaly_mock do expect(lfs_blob_ids).to eq([])
it_behaves_like '#lfs_blob_ids'
end end
end end
end end
...@@ -37,17 +37,7 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do ...@@ -37,17 +37,7 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
let(:stub_path) { '.gitignore' } let(:stub_path) { '.gitignore' }
end end
shared_examples 'initializes a DiffCollection' do it 'returns a valid instance of a DiffCollection' do
it 'returns a valid instance of a DiffCollection' do expect(diff_files).to be_a(Gitlab::Git::DiffCollection)
expect(diff_files).to be_a(Gitlab::Git::DiffCollection)
end
end
context 'with Gitaly disabled', :disable_gitaly do
it_behaves_like 'initializes a DiffCollection'
end
context 'with Gitaly enabled' do
it_behaves_like 'initializes a DiffCollection'
end end
end end
...@@ -128,7 +128,7 @@ describe Gitlab::Git::Blob, :seed_helper do ...@@ -128,7 +128,7 @@ describe Gitlab::Git::Blob, :seed_helper do
end end
end end
shared_examples 'finding blobs by ID' do describe '.raw' do
let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) } let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) }
let(:bad_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::BigCommit::ID) } let(:bad_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::BigCommit::ID) }
...@@ -166,16 +166,6 @@ describe Gitlab::Git::Blob, :seed_helper do ...@@ -166,16 +166,6 @@ describe Gitlab::Git::Blob, :seed_helper do
end end
end end
describe '.raw' do
context 'when the blob_raw Gitaly feature is enabled' do
it_behaves_like 'finding blobs by ID'
end
context 'when the blob_raw Gitaly feature is disabled', :skip_gitaly_mock do
it_behaves_like 'finding blobs by ID'
end
end
describe '.batch' do describe '.batch' do
let(:blob_references) do let(:blob_references) do
[ [
......
...@@ -183,110 +183,100 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -183,110 +183,100 @@ describe Gitlab::Git::Commit, :seed_helper do
end end
end end
shared_examples '.where' do context 'path is empty string' do
context 'path is empty string' do subject do
subject do commits = described_class.where(
commits = described_class.where( repo: repository,
repo: repository, ref: 'master',
ref: 'master', path: '',
path: '', limit: 10
limit: 10 )
)
commits.map { |c| c.id }
end
it 'has 10 elements' do commits.map { |c| c.id }
expect(subject.size).to eq(10)
end
it { is_expected.to include(SeedRepo::EmptyCommit::ID) }
end end
context 'path is nil' do it 'has 10 elements' do
subject do expect(subject.size).to eq(10)
commits = described_class.where(
repo: repository,
ref: 'master',
path: nil,
limit: 10
)
commits.map { |c| c.id }
end
it 'has 10 elements' do
expect(subject.size).to eq(10)
end
it { is_expected.to include(SeedRepo::EmptyCommit::ID) }
end end
it { is_expected.to include(SeedRepo::EmptyCommit::ID) }
end
context 'ref is branch name' do context 'path is nil' do
subject do subject do
commits = described_class.where( commits = described_class.where(
repo: repository, repo: repository,
ref: 'master', ref: 'master',
path: 'files', path: nil,
limit: 3, limit: 10
offset: 1 )
)
commits.map { |c| c.id } commits.map { |c| c.id }
end end
it 'has 3 elements' do it 'has 10 elements' do
expect(subject.size).to eq(3) expect(subject.size).to eq(10)
end
it { is_expected.to include("d14d6c0abdd253381df51a723d58691b2ee1ab08") }
it { is_expected.not_to include("eb49186cfa5c4338011f5f590fac11bd66c5c631") }
end end
it { is_expected.to include(SeedRepo::EmptyCommit::ID) }
end
context 'ref is commit id' do context 'ref is branch name' do
subject do subject do
commits = described_class.where( commits = described_class.where(
repo: repository, repo: repository,
ref: "874797c3a73b60d2187ed6e2fcabd289ff75171e", ref: 'master',
path: 'files', path: 'files',
limit: 3, limit: 3,
offset: 1 offset: 1
) )
commits.map { |c| c.id } commits.map { |c| c.id }
end end
it 'has 3 elements' do it 'has 3 elements' do
expect(subject.size).to eq(3) expect(subject.size).to eq(3)
end
it { is_expected.to include("2f63565e7aac07bcdadb654e253078b727143ec4") }
it { is_expected.not_to include(SeedRepo::Commit::ID) }
end end
it { is_expected.to include("d14d6c0abdd253381df51a723d58691b2ee1ab08") }
it { is_expected.not_to include("eb49186cfa5c4338011f5f590fac11bd66c5c631") }
end
context 'ref is tag' do context 'ref is commit id' do
subject do subject do
commits = described_class.where( commits = described_class.where(
repo: repository, repo: repository,
ref: 'v1.0.0', ref: "874797c3a73b60d2187ed6e2fcabd289ff75171e",
path: 'files', path: 'files',
limit: 3, limit: 3,
offset: 1 offset: 1
) )
commits.map { |c| c.id } commits.map { |c| c.id }
end end
it 'has 3 elements' do it 'has 3 elements' do
expect(subject.size).to eq(3) expect(subject.size).to eq(3)
end
it { is_expected.to include("874797c3a73b60d2187ed6e2fcabd289ff75171e") }
it { is_expected.not_to include(SeedRepo::Commit::ID) }
end end
it { is_expected.to include("2f63565e7aac07bcdadb654e253078b727143ec4") }
it { is_expected.not_to include(SeedRepo::Commit::ID) }
end end
describe '.where with gitaly' do context 'ref is tag' do
it_should_behave_like '.where' subject do
end commits = described_class.where(
repo: repository,
ref: 'v1.0.0',
path: 'files',
limit: 3,
offset: 1
)
describe '.where without gitaly', :skip_gitaly_mock do commits.map { |c| c.id }
it_should_behave_like '.where' end
it 'has 3 elements' do
expect(subject.size).to eq(3)
end
it { is_expected.to include("874797c3a73b60d2187ed6e2fcabd289ff75171e") }
it { is_expected.not_to include(SeedRepo::Commit::ID) }
end end
describe '.between' do describe '.between' do
...@@ -508,7 +498,7 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -508,7 +498,7 @@ describe Gitlab::Git::Commit, :seed_helper do
end end
end end
shared_examples '#stats' do describe '#stats' do
subject { commit.stats } subject { commit.stats }
describe '#additions' do describe '#additions' do
...@@ -527,14 +517,6 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -527,14 +517,6 @@ describe Gitlab::Git::Commit, :seed_helper do
end end
end end
describe '#stats with gitaly on' do
it_should_behave_like '#stats'
end
describe '#stats with gitaly disabled', :skip_gitaly_mock do
it_should_behave_like '#stats'
end
describe '#has_zero_stats?' do describe '#has_zero_stats?' do
it { expect(commit.has_zero_stats?).to eq(false) } it { expect(commit.has_zero_stats?).to eq(false) }
end end
...@@ -577,25 +559,15 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -577,25 +559,15 @@ describe Gitlab::Git::Commit, :seed_helper do
commit_ids.map { |id| described_class.get_message(repository, id) } commit_ids.map { |id| described_class.get_message(repository, id) }
end end
shared_examples 'getting commit messages' do it 'gets commit messages' do
it 'gets commit messages' do expect(subject).to contain_exactly(
expect(subject).to contain_exactly( "Added contributing guide\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n",
"Added contributing guide\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n", "Add submodule\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"
"Add submodule\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n" )
)
end
end
context 'when Gitaly commit_messages feature is enabled' do
it_behaves_like 'getting commit messages'
it 'gets messages in one batch', :request_store do
expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end
end end
context 'when Gitaly commit_messages feature is disabled', :disable_gitaly do it 'gets messages in one batch', :request_store do
it_behaves_like 'getting commit messages' expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end end
end end
......
...@@ -3,7 +3,7 @@ require "spec_helper" ...@@ -3,7 +3,7 @@ require "spec_helper"
describe Gitlab::Git::Tag, :seed_helper do describe Gitlab::Git::Tag, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
shared_examples 'Gitlab::Git::Repository#tags' do describe '#tags' do
describe 'first tag' do describe 'first tag' do
let(:tag) { repository.tags.first } let(:tag) { repository.tags.first }
...@@ -25,14 +25,6 @@ describe Gitlab::Git::Tag, :seed_helper do ...@@ -25,14 +25,6 @@ describe Gitlab::Git::Tag, :seed_helper do
it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) } it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) }
end end
context 'when Gitaly tags feature is enabled' do
it_behaves_like 'Gitlab::Git::Repository#tags'
end
context 'when Gitaly tags feature is disabled', :skip_gitaly_mock do
it_behaves_like 'Gitlab::Git::Repository#tags'
end
describe '.get_message' do describe '.get_message' do
let(:tag_ids) { %w[f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b] } let(:tag_ids) { %w[f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b] }
...@@ -40,23 +32,13 @@ describe Gitlab::Git::Tag, :seed_helper do ...@@ -40,23 +32,13 @@ describe Gitlab::Git::Tag, :seed_helper do
tag_ids.map { |id| described_class.get_message(repository, id) } tag_ids.map { |id| described_class.get_message(repository, id) }
end end
shared_examples 'getting tag messages' do it 'gets tag messages' do
it 'gets tag messages' do expect(subject[0]).to eq("Release\n")
expect(subject[0]).to eq("Release\n") expect(subject[1]).to eq("Version 1.1.0\n")
expect(subject[1]).to eq("Version 1.1.0\n")
end
end
context 'when Gitaly tag_messages feature is enabled' do
it_behaves_like 'getting tag messages'
it 'gets messages in one batch', :request_store do
expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end
end end
context 'when Gitaly tag_messages feature is disabled', :disable_gitaly do it 'gets messages in one batch', :request_store do
it_behaves_like 'getting tag messages' expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end end
end end
......
...@@ -80,18 +80,8 @@ describe Gitlab::Git::Tree, :seed_helper do ...@@ -80,18 +80,8 @@ describe Gitlab::Git::Tree, :seed_helper do
end end
describe '#where' do describe '#where' do
shared_examples '#where' do it 'returns an empty array when called with an invalid ref' do
it 'returns an empty array when called with an invalid ref' do expect(described_class.where(repository, 'foobar-does-not-exist')).to eq([])
expect(described_class.where(repository, 'foobar-does-not-exist')).to eq([])
end
end
context 'with gitaly' do
it_behaves_like '#where'
end
context 'without gitaly', :skip_gitaly_mock do
it_behaves_like '#where'
end end
end end
end end
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
# We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want # We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want
# those stubs while testing the GitalyClient itself. # those stubs while testing the GitalyClient itself.
describe Gitlab::GitalyClient, skip_gitaly_mock: true do describe Gitlab::GitalyClient do
describe '.stub_class' do describe '.stub_class' do
it 'returns the gRPC health check stub' do it 'returns the gRPC health check stub' do
expect(described_class.stub_class(:health_check)).to eq(::Grpc::Health::V1::Health::Stub) expect(described_class.stub_class(:health_check)).to eq(::Grpc::Health::V1::Health::Stub)
...@@ -191,102 +191,13 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do ...@@ -191,102 +191,13 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do
let(:feature_name) { 'my_feature' } let(:feature_name) { 'my_feature' }
let(:real_feature_name) { "gitaly_#{feature_name}" } let(:real_feature_name) { "gitaly_#{feature_name}" }
context 'when Gitaly is disabled' do before do
before do allow(Feature).to receive(:enabled?).and_return(false)
allow(described_class).to receive(:enabled?).and_return(false)
end
it 'returns false' do
expect(described_class.feature_enabled?(feature_name)).to be(false)
end
end
context 'when the feature status is DISABLED' do
let(:feature_status) { Gitlab::GitalyClient::MigrationStatus::DISABLED }
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context 'when the feature_status is OPT_IN' do
let(:feature_status) { Gitlab::GitalyClient::MigrationStatus::OPT_IN }
context "when the feature flag hasn't been set" do
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context "when the feature flag is set to disable" do
before do
Feature.get(real_feature_name).disable
end
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context "when the feature flag is set to enable" do
before do
Feature.get(real_feature_name).enable
end
it 'returns true' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
end
end
context "when the feature flag is set to a percentage of time" do
before do
Feature.get(real_feature_name).enable_percentage_of_time(70)
end
it 'bases the result on pseudo-random numbers' do
expect(Random).to receive(:rand).and_return(0.3)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
expect(Random).to receive(:rand).and_return(0.8)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context "when a feature is not persisted" do
it 'returns false when opt_into_all_features is off' do
allow(Feature).to receive(:persisted?).and_return(false)
allow(described_class).to receive(:opt_into_all_features?).and_return(false)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
it 'returns true when the override is on' do
allow(Feature).to receive(:persisted?).and_return(false)
allow(described_class).to receive(:opt_into_all_features?).and_return(true)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
end
end
end end
context 'when the feature_status is OPT_OUT' do it 'returns false' do
let(:feature_status) { Gitlab::GitalyClient::MigrationStatus::OPT_OUT } expect(Feature).to receive(:enabled?).with(real_feature_name)
expect(described_class.feature_enabled?(feature_name)).to be(false)
context "when the feature flag hasn't been set" do
it 'returns true' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
end
end
context "when the feature flag is set to disable" do
before do
Feature.get(real_feature_name).disable
end
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
end end
end end
...@@ -305,4 +216,29 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do ...@@ -305,4 +216,29 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do
end end
end end
end end
describe 'Peek Performance bar details' do
let(:gitaly_server) { Gitaly::Server.all.first }
before do
Gitlab::SafeRequestStore[:peek_enabled] = true
end
context 'when the request store is active', :request_store do
it 'records call details if a RPC is called' do
gitaly_server.server_version
expect(described_class.list_call_details).not_to be_empty
expect(described_class.list_call_details.size).to be(1)
end
end
context 'when no request store is active' do
it 'records nothing' do
gitaly_server.server_version
expect(described_class.list_call_details).to be_empty
end
end
end
end end
...@@ -30,48 +30,38 @@ describe MergeRequest do ...@@ -30,48 +30,38 @@ describe MergeRequest do
end end
describe '#squash_in_progress?' do describe '#squash_in_progress?' do
shared_examples 'checking whether a squash is in progress' do let(:repo_path) do
let(:repo_path) do Gitlab::GitalyClient::StorageSettings.allow_disk_access do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do subject.source_project.repository.path
subject.source_project.repository.path
end
end
let(:squash_path) { File.join(repo_path, "gitlab-worktree", "squash-#{subject.id}") }
before do
system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} worktree add --detach #{squash_path} master))
end
it 'returns true when there is a current squash directory' do
expect(subject.squash_in_progress?).to be_truthy
end end
end
let(:squash_path) { File.join(repo_path, "gitlab-worktree", "squash-#{subject.id}") }
it 'returns false when there is no squash directory' do before do
FileUtils.rm_rf(squash_path) system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} worktree add --detach #{squash_path} master))
end
expect(subject.squash_in_progress?).to be_falsey it 'returns true when there is a current squash directory' do
end expect(subject.squash_in_progress?).to be_truthy
end
it 'returns false when the squash directory has expired' do it 'returns false when there is no squash directory' do
time = 20.minutes.ago.to_time FileUtils.rm_rf(squash_path)
File.utime(time, time, squash_path)
expect(subject.squash_in_progress?).to be_falsey expect(subject.squash_in_progress?).to be_falsey
end end
it 'returns false when the source project has been removed' do it 'returns false when the squash directory has expired' do
allow(subject).to receive(:source_project).and_return(nil) time = 20.minutes.ago.to_time
File.utime(time, time, squash_path)
expect(subject.squash_in_progress?).to be_falsey expect(subject.squash_in_progress?).to be_falsey
end
end end
context 'when Gitaly squash_in_progress is enabled' do it 'returns false when the source project has been removed' do
it_behaves_like 'checking whether a squash is in progress' allow(subject).to receive(:source_project).and_return(nil)
end
context 'when Gitaly squash_in_progress is disabled', :disable_gitaly do expect(subject.squash_in_progress?).to be_falsey
it_behaves_like 'checking whether a squash is in progress'
end end
end end
...@@ -3016,14 +3006,6 @@ describe MergeRequest do ...@@ -3016,14 +3006,6 @@ describe MergeRequest do
expect(subject.rebase_in_progress?).to be_falsey expect(subject.rebase_in_progress?).to be_falsey
end end
end end
context 'when Gitaly rebase_in_progress is enabled' do
it_behaves_like 'checking whether a rebase is in progress'
end
context 'when Gitaly rebase_in_progress is enabled', :disable_gitaly do
it_behaves_like 'checking whether a rebase is in progress'
end
end end
describe '#allow_collaboration' do describe '#allow_collaboration' do
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# frozen_string_literal: true
require 'spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../rubocop/cop/safe_params'
describe RuboCop::Cop::SafeParams do
include CopHelper
subject(:cop) { described_class.new }
it 'flags the params as an argument of url_for' do
expect_offense(<<~SOURCE)
url_for(params)
^^^^^^^^^^^^^^^ Use `safe_params` instead of `params` in url_for.
SOURCE
end
it 'flags the merged params as an argument of url_for' do
expect_offense(<<~SOURCE)
url_for(params.merge(additional_params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `safe_params` instead of `params` in url_for.
SOURCE
end
it 'flags the merged params arg as an argument of url_for' do
expect_offense(<<~SOURCE)
url_for(something.merge(additional).merge(params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `safe_params` instead of `params` in url_for.
SOURCE
end
it 'does not flag other argument of url_for' do
expect_no_offenses(<<~SOURCE)
url_for(something)
SOURCE
end
end
RSpec.configure do |config|
config.before(:each) do |example|
if example.metadata[:disable_gitaly]
# Use 'and_wrap_original' to make sure the arguments are valid
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_wrap_original { |m, *args| m.call(*args) && false }
else
next if example.metadata[:skip_gitaly_mock]
# Use 'and_wrap_original' to make sure the arguments are valid
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_wrap_original do |m, *args|
m.call(*args)
!Gitlab::GitalyClient.explicit_opt_in_required.include?(args.first)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment