diff options
90 files changed, 1049 insertions, 559 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index ae6f633fd60..860d57d89a0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -301,12 +301,6 @@ RSpec/AnyInstanceOf: Enabled: false # Cops for upgrade to gitlab-styles 3.1.0 -RSpec/ReceiveCounts: - Enabled: false - -RSpec/ContextMethod: - Enabled: false - RSpec/ImplicitSubject: Enabled: false @@ -343,6 +337,7 @@ RSpec/MissingExampleGroupArgument: RSpec/UnspecifiedException: Enabled: false +# Work in progress. See https://gitlab.com/gitlab-org/gitlab/issues/196163 RSpec/HaveGitlabHttpStatus: Enabled: true Include: @@ -350,6 +345,8 @@ RSpec/HaveGitlabHttpStatus: - 'ee/spec/support/shared_examples/**/*' - 'spec/features/**/*' - 'ee/spec/features/**/*' + - 'spec/controllers/*.rb' + - 'ee/spec/controllers/*.rb' Style/MultilineWhenThen: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a2a208ea6b5..ad9e255e93b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -782,3 +782,129 @@ Style/UnneededSort: Exclude: - 'app/models/concerns/resolvable_discussion.rb' - 'lib/gitlab/highlight.rb' + +RSpec/ReceiveCounts: + Exclude: + - 'ee/spec/models/broadcast_message_spec.rb' + - 'ee/spec/services/geo/project_housekeeping_service_spec.rb' + - 'ee/spec/services/geo/repository_sync_service_spec.rb' + - 'spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb' + - 'spec/lib/gitlab/ci/trace/section_parser_spec.rb' + - 'spec/lib/gitlab/cleanup/project_uploads_spec.rb' + - 'spec/lib/gitlab/danger/teammate_spec.rb' + - 'spec/lib/gitlab/git_access_spec.rb' + - 'spec/lib/gitlab/gpg_spec.rb' + - 'spec/lib/gitlab/legacy_github_import/importer_spec.rb' + - 'spec/lib/gitlab/sanitizers/exif_spec.rb' + - 'spec/models/concerns/avatarable_spec.rb' + - 'spec/models/concerns/triggerable_hooks_spec.rb' + - 'spec/requests/api/graphql_spec.rb' + - 'spec/services/ci/ensure_stage_service_spec.rb' + - 'spec/services/clusters/cleanup/app_service_spec.rb' + - 'spec/services/notification_service_spec.rb' + - 'spec/services/projects/housekeeping_service_spec.rb' + - 'spec/tasks/gitlab/cleanup_rake_spec.rb' + - 'spec/uploaders/gitlab_uploader_spec.rb' + - 'spec/workers/create_gpg_signature_worker_spec.rb' + +RSpec/ContextMethod: + Exclude: + - 'ee/spec/controllers/ee/projects/autocomplete_sources_controller_spec.rb' + - 'ee/spec/controllers/groups/autocomplete_sources_controller_spec.rb' + - 'ee/spec/finders/geo/file_registry_finder_spec.rb' + - 'ee/spec/helpers/feature_flags_helper_spec.rb' + - 'ee/spec/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb' + - 'ee/spec/lib/ee/gitlab/ci/config/entry/trigger_spec.rb' + - 'ee/spec/lib/elastic/latest/snippet_instance_proxy_spec.rb' + - 'ee/spec/lib/gitlab/contribution_analytics/data_collector_spec.rb' + - 'ee/spec/lib/gitlab/geo/replication/file_transfer_spec.rb' + - 'ee/spec/lib/gitlab/geo/replication/job_artifact_downloader_spec.rb' + - 'ee/spec/lib/gitlab/geo/replication/job_artifact_retriever_spec.rb' + - 'ee/spec/lib/gitlab/geo/replication/job_artifact_transfer_spec.rb' + - 'ee/spec/lib/gitlab/geo/replication/lfs_downloader_spec.rb' + - 'ee/spec/lib/gitlab/geo/replication/lfs_retriever_spec.rb' + - 'ee/spec/lib/gitlab/geo/replication/lfs_transfer_spec.rb' + - 'ee/spec/lib/gitlab/geo_spec.rb' + - 'ee/spec/models/approval_state_spec.rb' + - 'ee/spec/models/approval_wrapped_any_approver_rule_spec.rb' + - 'ee/spec/models/concerns/approval_rule_like_spec.rb' + - 'ee/spec/models/concerns/elastic/issue_spec.rb' + - 'ee/spec/models/concerns/elastic/note_spec.rb' + - 'ee/spec/models/concerns/elastic/project_spec.rb' + - 'ee/spec/models/concerns/epic_tree_sorting_spec.rb' + - 'ee/spec/models/concerns/has_timelogs_report_spec.rb' + - 'ee/spec/models/ee/clusters/applications/prometheus_spec.rb' + - 'ee/spec/models/ee/clusters/platforms/kubernetes_spec.rb' + - 'ee/spec/models/user_spec.rb' + - 'ee/spec/presenters/ci/pipeline_presenter_spec.rb' + - 'ee/spec/requests/api/epics_spec.rb' + - 'ee/spec/services/boards/update_service_spec.rb' + - 'ee/spec/services/ee/boards/issues/list_service_spec.rb' + - 'ee/spec/services/ee/merge_requests/refresh_service_spec.rb' + - 'ee/spec/services/groups/update_service_spec.rb' + - 'ee/spec/services/projects/create_from_template_service_spec.rb' + - 'ee/spec/services/projects/update_service_spec.rb' + - 'ee/spec/services/update_build_minutes_service_spec.rb' + - 'ee/spec/support/shared_examples/features/gold_trial_callout_shared_examples.rb' + - 'ee/spec/support/shared_examples/models/concerns/elastic/limited_indexing_shared_examples.rb' + - 'qa/spec/ee/scenario/test/integration/group_saml_spec.rb' + - 'qa/spec/resource/api_fabricator_spec.rb' + - 'qa/spec/scenario/test/integration/github_spec.rb' + - 'qa/spec/scenario/test/integration/instance_saml_spec.rb' + - 'qa/spec/scenario/test/integration/kubernetes_spec.rb' + - 'qa/spec/scenario/test/integration/ldap_spec.rb' + - 'qa/spec/scenario/test/integration/mattermost_spec.rb' + - 'qa/spec/scenario/test/integration/oauth_spec.rb' + - 'qa/spec/scenario/test/integration/object_storage_spec.rb' + - 'qa/spec/specs/runner_spec.rb' + - 'spec/controllers/application_controller_spec.rb' + - 'spec/controllers/projects/milestones_controller_spec.rb' + - 'spec/features/projects/blobs/blob_show_spec.rb' + - 'spec/finders/concerns/finder_with_cross_project_access_spec.rb' + - 'spec/helpers/diff_helper_spec.rb' + - 'spec/helpers/nav_helper_spec.rb' + - 'spec/helpers/sourcegraph_helper_spec.rb' + - 'spec/lib/container_registry/registry_spec.rb' + - 'spec/lib/container_registry/tag_spec.rb' + - 'spec/lib/gitlab/ci/trace/chunked_io_spec.rb' + - 'spec/lib/gitlab/content_security_policy/config_loader_spec.rb' + - 'spec/lib/gitlab/database/count_spec.rb' + - 'spec/lib/gitlab/git/rugged_impl/use_rugged_spec.rb' + - 'spec/lib/gitlab/git_ref_validator_spec.rb' + - 'spec/lib/gitlab/private_commit_email_spec.rb' + - 'spec/lib/gitlab/rugged_instrumentation_spec.rb' + - 'spec/lib/omni_auth/strategies/jwt_spec.rb' + - 'spec/lib/safe_zip/entry_spec.rb' + - 'spec/lib/safe_zip/extract_spec.rb' + - 'spec/models/badge_spec.rb' + - 'spec/models/badges/project_badge_spec.rb' + - 'spec/models/ci/artifact_blob_spec.rb' + - 'spec/models/ci/persistent_ref_spec.rb' + - 'spec/models/ci/runner_spec.rb' + - 'spec/models/concerns/routable_spec.rb' + - 'spec/models/deployment_spec.rb' + - 'spec/models/issue_spec.rb' + - 'spec/models/notification_recipient_spec.rb' + - 'spec/models/project_services/bamboo_service_spec.rb' + - 'spec/models/project_services/buildkite_service_spec.rb' + - 'spec/models/project_services/chat_message/issue_message_spec.rb' + - 'spec/models/project_services/drone_ci_service_spec.rb' + - 'spec/models/project_services/hipchat_service_spec.rb' + - 'spec/models/project_services/jira_service_spec.rb' + - 'spec/models/project_spec.rb' + - 'spec/models/remote_mirror_spec.rb' + - 'spec/models/user_spec.rb' + - 'spec/models/wiki_page_spec.rb' + - 'spec/requests/api/issues/get_group_issues_spec.rb' + - 'spec/requests/api/merge_requests_spec.rb' + - 'spec/serializers/diff_file_entity_spec.rb' + - 'spec/services/branches/delete_merged_service_spec.rb' + - 'spec/services/labels/available_labels_service_spec.rb' + - 'spec/services/projects/batch_open_issues_count_service_spec.rb' + - 'spec/services/projects/destroy_service_spec.rb' + - 'spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb' + - 'spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb' + - 'spec/services/projects/open_issues_count_service_spec.rb' + - 'spec/services/quick_actions/interpret_service_spec.rb' + - 'spec/support/shared_examples/services/boards/issues_list_service_shared_examples.rb' + - 'spec/uploaders/namespace_file_uploader_spec.rb'
\ No newline at end of file diff --git a/app/assets/javascripts/filtered_search/dropdown_operator.js b/app/assets/javascripts/filtered_search/dropdown_operator.js index bd4fda29609..d9794e326f8 100644 --- a/app/assets/javascripts/filtered_search/dropdown_operator.js +++ b/app/assets/javascripts/filtered_search/dropdown_operator.js @@ -45,13 +45,13 @@ export default class DropdownOperator extends FilteredSearchDropdown { tag: 'equal', type: 'string', title: '=', - help: __('Is'), + help: __('is'), }, { tag: 'not-equal', type: 'string', title: '!=', - help: __('Is not'), + help: __('is not'), }, ]; this.droplab.changeHookList(this.hookId, this.dropdown, [Filter], this.config); diff --git a/app/assets/javascripts/ide/services/index.js b/app/assets/javascripts/ide/services/index.js index b130e6e8b81..a5134c64705 100644 --- a/app/assets/javascripts/ide/services/index.js +++ b/app/assets/javascripts/ide/services/index.js @@ -35,6 +35,7 @@ export default { joinPaths( gon.relative_url_root || '/', file.projectId, + '-', 'raw', sha, escapeFileUrl(filePath), @@ -67,7 +68,7 @@ export default { return Api.commitMultiple(projectId, payload); }, getFiles(projectUrl, ref) { - const url = `${projectUrl}/files/${ref}`; + const url = `${projectUrl}/-/files/${ref}`; return axios.get(url, { params: { format: 'json' } }); }, lastCommitPipelines({ getters }) { diff --git a/app/assets/javascripts/repository/components/breadcrumbs.vue b/app/assets/javascripts/repository/components/breadcrumbs.vue index 5917c96990e..f306910df05 100644 --- a/app/assets/javascripts/repository/components/breadcrumbs.vue +++ b/app/assets/javascripts/repository/components/breadcrumbs.vue @@ -107,10 +107,10 @@ export default { return acc.concat({ name, path, - to: `/tree/${this.ref}${path}`, + to: `/-/tree/${this.ref}${path}`, }); }, - [{ name: this.projectShortPath, path: '/', to: `/tree/${this.ref}/` }], + [{ name: this.projectShortPath, path: '/', to: `/-/tree/${this.ref}/` }], ); }, canCreateMrFromFork() { diff --git a/app/assets/javascripts/repository/components/table/parent_row.vue b/app/assets/javascripts/repository/components/table/parent_row.vue index 70a188f98cc..c919f2d42cb 100644 --- a/app/assets/javascripts/repository/components/table/parent_row.vue +++ b/app/assets/javascripts/repository/components/table/parent_row.vue @@ -28,7 +28,7 @@ export default { return splitArray.join('/'); }, parentRoute() { - return { path: `/tree/${this.commitRef}/${this.parentPath}` }; + return { path: `/-/tree/${this.commitRef}/${this.parentPath}` }; }, }, methods: { diff --git a/app/assets/javascripts/repository/components/table/row.vue b/app/assets/javascripts/repository/components/table/row.vue index a8e13241c37..a0a9a5657a8 100644 --- a/app/assets/javascripts/repository/components/table/row.vue +++ b/app/assets/javascripts/repository/components/table/row.vue @@ -90,7 +90,7 @@ export default { }, computed: { routerLinkTo() { - return this.isFolder ? { path: `/tree/${this.ref}/${this.path}` } : null; + return this.isFolder ? { path: `/-/tree/${this.ref}/${this.path}` } : null; }, iconName() { return `fa-${getIconName(this.type, this.path)}`; diff --git a/app/assets/javascripts/repository/router.js b/app/assets/javascripts/repository/router.js index ebf0a7091ea..fa544444be8 100644 --- a/app/assets/javascripts/repository/router.js +++ b/app/assets/javascripts/repository/router.js @@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) { base: joinPaths(gon.relative_url_root || '', base), routes: [ { - path: `/tree/${baseRef}(/.*)?`, + path: `/-/tree/${baseRef}(/.*)?`, name: 'treePath', component: TreePage, props: route => ({ diff --git a/app/assets/javascripts/vue_shared/components/diff_viewer/diff_viewer.vue b/app/assets/javascripts/vue_shared/components/diff_viewer/diff_viewer.vue index b874bedab36..bf3c3666300 100644 --- a/app/assets/javascripts/vue_shared/components/diff_viewer/diff_viewer.vue +++ b/app/assets/javascripts/vue_shared/components/diff_viewer/diff_viewer.vue @@ -79,10 +79,10 @@ export default { return this.projectPath.indexOf('/') === 0 ? '' : `${gon.relative_url_root}/`; }, fullOldPath() { - return `${this.basePath}${this.projectPath}/raw/${this.oldSha}/${this.oldPath}`; + return `${this.basePath}${this.projectPath}/-/raw/${this.oldSha}/${this.oldPath}`; }, fullNewPath() { - return `${this.basePath}${this.projectPath}/raw/${this.newSha}/${this.newPath}`; + return `${this.basePath}${this.projectPath}/-/raw/${this.newSha}/${this.newPath}`; }, }, }; diff --git a/app/assets/javascripts/vue_shared/components/pagination/graphql_pagination.vue b/app/assets/javascripts/vue_shared/components/pagination/graphql_pagination.vue deleted file mode 100644 index 53e473432db..00000000000 --- a/app/assets/javascripts/vue_shared/components/pagination/graphql_pagination.vue +++ /dev/null @@ -1,47 +0,0 @@ -<script> -import { GlButton } from '@gitlab/ui'; -import { PREV, NEXT } from '~/vue_shared/components/pagination/constants'; - -/** - * Pagination Component for graphql API - */ -export default { - name: 'GraphqlPaginationComponent', - components: { - GlButton, - }, - labels: { - prev: PREV, - next: NEXT, - }, - props: { - hasNextPage: { - required: true, - type: Boolean, - }, - hasPreviousPage: { - required: true, - type: Boolean, - }, - }, -}; -</script> -<template> - <div class="justify-content-center d-flex prepend-top-default"> - <div class="btn-group"> - <gl-button - class="js-prev-btn page-link" - :disabled="!hasPreviousPage" - @click="$emit('previousClicked')" - >{{ $options.labels.prev }}</gl-button - > - - <gl-button - class="js-next-btn page-link" - :disabled="!hasNextPage" - @click="$emit('nextClicked')" - >{{ $options.labels.next }}</gl-button - > - </div> - </div> -</template> diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 9707a5cef3b..32c613ab4ad 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -39,9 +39,9 @@ module SubmoduleHelper elsif relative_self_url?(url) relative_self_links(url, submodule_item_id, repository.project) elsif github_dot_com_url?(url) - standard_links('github.com', namespace, project, submodule_item_id) + github_com_tree_links(namespace, project, submodule_item_id) elsif gitlab_dot_com_url?(url) - standard_links('gitlab.com', namespace, project, submodule_item_id) + gitlab_com_tree_links(namespace, project, submodule_item_id) else [sanitize_submodule_url(url), nil] end @@ -73,8 +73,13 @@ module SubmoduleHelper url.start_with?('../', './') end - def standard_links(host, namespace, project, commit) - base = ['https://', host, '/', namespace, '/', project].join('') + def gitlab_com_tree_links(namespace, project, commit) + base = ['https://gitlab.com/', namespace, '/', project].join('') + [base, [base, '/-/tree/', commit].join('')] + end + + def github_com_tree_links(namespace, project, commit) + base = ['https://github.com/', namespace, '/', project].join('') [base, [base, '/tree/', commit].join('')] end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index af1919eeb40..0b50b8b1130 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -38,13 +38,13 @@ module TreeHelper # many paths, as with a repository tree that has thousands of items. def fast_project_blob_path(project, blob_path) ActionDispatch::Journey::Router::Utils.escape_path( - File.join(relative_url_root, project.path_with_namespace, 'blob', blob_path) + File.join(relative_url_root, project.path_with_namespace, '-', 'blob', blob_path) ) end def fast_project_tree_path(project, tree_path) ActionDispatch::Journey::Router::Utils.escape_path( - File.join(relative_url_root, project.path_with_namespace, 'tree', tree_path) + File.join(relative_url_root, project.path_with_namespace, '-', 'tree', tree_path) ) end diff --git a/app/models/key.rb b/app/models/key.rb index 71188f210bb..e729ef67346 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -96,8 +96,7 @@ class Key < ApplicationRecord def remove_from_shell GitlabShellWorker.perform_async( :remove_key, - shell_id, - key + shell_id ) end diff --git a/app/models/repository.rb b/app/models/repository.rb index ebb653cabce..ba0b87b7429 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -447,6 +447,8 @@ class Repository def after_import expire_content_cache + return unless repo_type.project? + # This call is stubbed in tests due to being an expensive operation # It can be reenabled for specific tests via: # diff --git a/changelogs/unreleased/198655-lowercase-operator.yml b/changelogs/unreleased/198655-lowercase-operator.yml new file mode 100644 index 00000000000..2c5cec474f6 --- /dev/null +++ b/changelogs/unreleased/198655-lowercase-operator.yml @@ -0,0 +1,5 @@ +--- +title: Switch dropdown operators to lowercase +merge_request: +author: +type: other diff --git a/changelogs/unreleased/35792-saml-bypass-2-factor-authentication-function-does-not-work-with-adf.yml b/changelogs/unreleased/35792-saml-bypass-2-factor-authentication-function-does-not-work-with-adf.yml new file mode 100644 index 00000000000..cc75ed3fbe5 --- /dev/null +++ b/changelogs/unreleased/35792-saml-bypass-2-factor-authentication-function-does-not-work-with-adf.yml @@ -0,0 +1,5 @@ +--- +title: Support the bypass 2FA function with ADFS SAML +merge_request: 23615 +author: +type: fixed diff --git a/changelogs/unreleased/do-not-create-pre-post-pipeline.yml b/changelogs/unreleased/do-not-create-pre-post-pipeline.yml new file mode 100644 index 00000000000..044cd2d0cf2 --- /dev/null +++ b/changelogs/unreleased/do-not-create-pre-post-pipeline.yml @@ -0,0 +1,5 @@ +--- +title: Require other stages than .pre and .post +merge_request: 23629 +author: +type: fixed diff --git a/changelogs/unreleased/dz-scope-repository-routes.yml b/changelogs/unreleased/dz-scope-repository-routes.yml new file mode 100644 index 00000000000..302227dde57 --- /dev/null +++ b/changelogs/unreleased/dz-scope-repository-routes.yml @@ -0,0 +1,5 @@ +--- +title: Move repository routes under - scope +merge_request: 20455 +author: +type: deprecated diff --git a/changelogs/unreleased/fj-avoid-calling-detect-languages-worker-wiki-repos.yml b/changelogs/unreleased/fj-avoid-calling-detect-languages-worker-wiki-repos.yml new file mode 100644 index 00000000000..b83e8effbdb --- /dev/null +++ b/changelogs/unreleased/fj-avoid-calling-detect-languages-worker-wiki-repos.yml @@ -0,0 +1,5 @@ +--- +title: Call DetectRepositoryLanguagesWorker only for project repositories +merge_request: 23696 +author: +type: fixed diff --git a/config/routes/project.rb b/config/routes/project.rb index f85267b66b3..df505f96c9d 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -286,6 +286,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do # The wiki and repository routing contains wildcard characters so # its preferable to keep it below all other project routes draw :repository_scoped + draw :repository draw :wiki end # End of the /-/ scope. @@ -476,14 +477,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do post :web_ide_clientside_preview end - # The repository routing contains wildcard characters so - # its preferable to keep it below all other project routes - draw :repository - - # To ensure an old unscoped routing is used for the UI we need to - # add prefix 'as' to the scope routing and place it below original routing. + # Deprecated unscoped routing. # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 - scope '-', as: 'scoped' do + scope as: 'deprecated' do draw :repository end diff --git a/doc/administration/gitaly/praefect.md b/doc/administration/gitaly/praefect.md index 7ccf15434c4..ebdfd8f1695 100644 --- a/doc/administration/gitaly/praefect.md +++ b/doc/administration/gitaly/praefect.md @@ -91,7 +91,7 @@ Below we assume that you have administrative access as the `postgres` user. First open a `psql` session as the `postgres` user: ```shell -psql -h POSTGRESQL_SERVER -U postgres -d template1 +/opt/gitlab/embedded/bin/psql -h POSTGRESQL_SERVER -U postgres -d template1 ``` Once you are connected, run the following command. Replace @@ -100,21 +100,21 @@ generated for the `praefect` SQL user: ```sql CREATE ROLE praefect WITH LOGIN CREATEDB PASSWORD 'PRAEFECT_SQL_PASSWORD'; -\q # exit psql +\q ``` Now connect as the `praefect` user to create the database. This has the side effect of verifying that you have access: ```shell -psql -h POSTGRESQL_SERVER -U praefect -d template1 +/opt/gitlab/embedded/bin/psql -h POSTGRESQL_SERVER -U praefect -d template1 ``` Once you have connected as the `praefect` user, run: ```sql CREATE DATABASE praefect_production WITH ENCODING=UTF8; -\q # quit psql +\q ``` #### Praefect @@ -260,9 +260,17 @@ git_data_dirs({ For more information on Gitaly server configuration, see our [Gitaly documentation](index.md#3-gitaly-server-configuration). +When finished editing the configuration file for each Gitaly server, run the +reconfigure command to put changes into effect: + +```shell +sudo gitlab-ctl reconfigure +``` + When all Gitaly servers are configured, you can run the Praefect connection checker to verify Praefect can connect to all Gitaly servers in the Praefect -config: +config. This can be done by running the following command on the Praefect +server: ```shell sudo /opt/gitlab/embedded/bin/praefect -config /var/opt/gitlab/praefect/config.toml dial-nodes diff --git a/doc/development/fe_guide/vuex.md b/doc/development/fe_guide/vuex.md index 20abf4fcb3e..0bb9e3b7d50 100644 --- a/doc/development/fe_guide/vuex.md +++ b/doc/development/fe_guide/vuex.md @@ -396,3 +396,93 @@ export default () => {}; ``` [vuex-docs]: https://vuex.vuejs.org + +### Two way data binding + +When storing form data in Vuex, it is sometimes necessary to update the value stored. The store should never be mutated directly, and an action should be used instead. +In order to still use `v-model` in our code, we need to create computed properties in this form: + +```javascript +export default { + computed: { + someValue: { + get() { + return this.$store.state.someValue; + }, + set(value) { + this.$store.dispatch("setSomeValue", value); + } + } + } +}; +``` + +An alternative is to use `mapState` and `mapActions`: + +```javascript +export default { + computed: { + ...mapState(['someValue']), + localSomeValue: { + get() { + return this.someValue; + }, + set(value) { + this.setSomeValue(value) + } + } + }, + methods: { + ...mapActions(['setSomeValue']) + } +}; +``` + +Adding a few of these properties becomes cumbersome, and makes the code more repetitive with more tests to write. To simplify this there is a helper in `~/vuex_shared/bindings.js` + +The helper can be used like so: + +```javascript +// this store is non-functional and only used to give context to the example +export default { + state: { + baz: '', + bar: '', + foo: '' + }, + actions: { + updateBar() {...} + updateAll() {...} + }, + getters: { + getFoo() {...} + } +} +``` + +```javascript +import { mapComputed } from '~/vuex_shared/bindings' +export default { + computed: { + /** + * @param {(string[]|Object[])} list - list of string matching state keys or list objects + * @param {string} list[].key - the key matching the key present in the vuex state + * @param {string} list[].getter - the name of the getter, leave it empty to not use a getter + * @param {string} list[].updateFn - the name of the action, leave it empty to use the default action + * @param {string} defaultUpdateFn - the default function to dispatch + * @param {string} root - optional key of the state where to search fo they keys described in list + * @returns {Object} a dictionary with all the computed properties generated + */ + ...mapComputed( + [ + 'baz', + { key: 'bar', updateFn: 'updateBar' } + { key: 'foo', getter: 'getFoo' }, + ], + 'updateAll', + ), + } +} +``` + +`mapComputed` will then generate the appropriate computed properties that get the data from the store and dispatch the correct action when updated. diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md index a845b5a26e8..78702ce173c 100644 --- a/doc/development/testing_guide/best_practices.md +++ b/doc/development/testing_guide/best_practices.md @@ -532,20 +532,24 @@ This is especially useful whenever it's showing 500 internal server error. ### Shared contexts -All shared contexts should be placed under `spec/support/shared_contexts/`. -Shared contexts can be placed in subfolder if they apply to a certain type of -specs only (e.g. features, requests etc.) but shouldn't be if they apply to -multiple type of specs. +Shared contexts only used in one spec file can be declared inline. +Any shared contexts used by more than one spec file: + +- Should be placed under `spec/support/shared_contexts/`. +- Can be placed in subfolder if they apply to a certain type of specs only + (e.g. features, requests etc.) but shouldn't be if they apply to multiple type of specs. Each file should include only one context and have a descriptive name, e.g. `spec/support/shared_contexts/controllers/githubish_import_controller_shared_context.rb`. ### Shared examples -All shared examples should be placed under `spec/support/shared_examples/`. -Shared examples can be placed in subfolder if they apply to a certain type of -specs only (e.g. features, requests etc.) but shouldn't be if they apply to -multiple type of specs. +Shared examples only used in one spec file can be declared inline. +Any shared examples used by more than one spec file: + +- Should be placed under `spec/support/shared_examples/`. +- Can be placed in subfolder if they apply to a certain type of specs only + (e.g. features, requests etc.) but shouldn't be if they apply to multiple type of specs. Each file should include only one context and have a descriptive name, e.g. `spec/support/shared_examples/controllers/githubish_import_controller_shared_example.rb`. diff --git a/doc/user/application_security/index.md b/doc/user/application_security/index.md index dbbcb606ac7..a3bfe5e69e8 100644 --- a/doc/user/application_security/index.md +++ b/doc/user/application_security/index.md @@ -40,7 +40,7 @@ The various scanning tools and the vulnerabilities database are updated regularl |:-------------------------------------------------------------|-------------------------------------------| | [Container Scanning](container_scanning/index.md) | Uses `clair` underneath and the latest `clair-db` version is used for each job run by running the [`latest` docker image tag](https://gitlab.com/gitlab-org/gitlab/blob/438a0a56dc0882f22bdd82e700554525f552d91b/lib/gitlab/ci/templates/Security/Container-Scanning.gitlab-ci.yml#L37). The `clair-db` database [is updated daily according to the author](https://github.com/arminc/clair-local-scan#clair-server-or-local). | | [Dependency Scanning](dependency_scanning/index.md) | Relies on `bundler-audit` (for Rubygems), `retire.js` (for NPM packages) and `gemnasium` (GitLab's own tool for all libraries). `bundler-audit` and `retire.js` both fetch their vulnerabilities data from GitHub repositories, so vulnerabilities added to `ruby-advisory-db` and `retire.js` are immediately available. The tools themselves are updated once per month if there's a new version. The [Gemnasium DB](https://gitlab.com/gitlab-org/security-products/gemnasium-db) is updated at least once a week. | -| [Dynamic Application Security Testing (DAST)](dast/index.md) | Updated weekly on Sundays. The underlying tool, `zaproxy`, downloads fresh rules at startup. | +| [Dynamic Application Security Testing (DAST)](dast/index.md) | The scanning engine is updated on a periodic basis. See the [version of the underlying tool `zaproxy`](https://gitlab.com/gitlab-org/security-products/dast/blob/master/Dockerfile#L1). The scanning rules are downloaded at the runtime of the scan. | | [Static Application Security Testing (SAST)](sast/index.md) | Relies exclusively on [the tools GitLab is wrapping](sast/index.md#supported-languages-and-frameworks). The underlying analyzers are updated at least once per month if a relevant update is available. The vulnerabilities database is updated by the upstream tools. | You don't have to update GitLab to benefit from the latest vulnerabilities definitions, diff --git a/doc/user/packages/npm_registry/index.md b/doc/user/packages/npm_registry/index.md index 5fdbbcedfc9..a0c82fd3e3c 100644 --- a/doc/user/packages/npm_registry/index.md +++ b/doc/user/packages/npm_registry/index.md @@ -28,52 +28,87 @@ You should then be able to see the **Packages** section on the left sidebar. Before proceeding to authenticating with the GitLab NPM Registry, you should get familiar with the package naming convention. -## Package naming convention +## Getting started -**Packages must be scoped in the root namespace of the project**. The package -name may be anything but it is preferred that the project name be used unless -it is not possible due to a naming collision. For example: +This section will cover installing NPM (or Yarn) and building a package for your +JavaScript project. This is a quickstart if you are new to NPM packages. If you +are already using NPM and understand how to build your own packages, move on to +the [next section](#authenticating-to-the-gitlab-npm-registry). -| Project | Package | Supported | -| ---------------------- | ----------------------- | --------- | -| `foo/bar` | `@foo/bar` | Yes | -| `foo/bar/baz` | `@foo/baz` | Yes | -| `foo/bar/buz` | `@foo/anything` | Yes | -| `gitlab-org/gitlab` | `@gitlab-org/gitlab` | Yes | -| `gitlab-org/gitlab` | `@foo/bar` | No | +### Installing NPM -The regex that is used for naming is validating all package names from all package managers: +Follow the instructions at [npmjs.com](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to download and install Node.JS and +NPM to your local development environment. + +Once installation is complete, verify you can use NPM in your terminal by +running: +```sh +npm --version ``` -/\A\@?(([\w\-\.\+]*)\/)*([\w\-\.]+)@?(([\w\-\.\+]*)\/)*([\w\-\.]*)\z/ + +You should see the NPM version printed in the output: + +``` +6.10.3 ``` -It allows for capital letters, while NPM does not, and allows for almost all of the -characters NPM allows with a few exceptions (`~` is not allowed). +### Installing Yarn -NOTE: **Note:** Capital letters are needed because the scope is required to be -identical to the top level namespace of the project. So, for example, if your -project path is `My-Group/project-foo`, your package must be named `@My-Group/any-package-name`. -`@my-group/any-package-name` will not work. +You may want to install and use Yarn as an alternative to NPM. Follow the +instructions at [yarnpkg.com](https://yarnpkg.com/en/docs/install) to install on +your development environment. -CAUTION: **When updating the path of a user/group or transferring a (sub)group/project:** -If you update the root namespace of a project with NPM packages, your changes will be rejected. To be allowed to do that, make sure to remove any NPM package first. Don't forget to update your `.npmrc` files to follow the above naming convention and run `npm publish` if necessary. +Once installed, you can verify that Yarn is available with the following command: -Now, you can configure your project to authenticate with the GitLab NPM -Registry. +```sh +yarn --version +``` + +You should see the version printed like so: + +``` +1.19.1 +``` + +### Creating a project + +Understanding how to create a full JavaScript project is outside the scope of +this guide but you can initialize a new empty package by creating and navigating +to an empty directory and using the following command: + +```sh +npm init +``` + +Or if you're using Yarn: + +```sh +yarn init +``` + +This will take you through a series of questions to produce a `package.json` +file, which is required for all NPM packages. The most important question is the +package name. NPM packages must [follow the naming convention](#package-naming-convention) +and be scoped to the project or group where the registry exists. + +Once you have completed the setup, you are now ready to upload your package to +the GitLab registry. To get started, you will need to set up authentication then +configure GitLab as a remote registry. ## Authenticating to the GitLab NPM Registry If a project is private or you want to upload an NPM package to GitLab, -credentials will need to be provided for authentication. Support is available for [OAuth tokens](../../../api/oauth2.md#resource-owner-password-credentials-flow) or [personal access tokens](../../profile/personal_access_tokens.md). +credentials will need to be provided for authentication. [Personal access tokens](../../profile/personal_access_tokens.md) +are preferred, but support is available for [OAuth tokens](../../../api/oauth2.md#resource-owner-password-credentials-flow). CAUTION: **2FA is only supported with personal access tokens:** If you have 2FA enabled, you need to use a [personal access token](../../profile/personal_access_tokens.md) with OAuth headers with the scope set to `api`. Standard OAuth tokens won't be able to authenticate to the GitLab NPM Registry. -### Authenticating with an OAuth token +### Authenticating with a personal access token -To authenticate with an [OAuth token](../../../api/oauth2.md#resource-owner-password-credentials-flow) -or [personal access token](../../profile/personal_access_tokens.md), set your NPM configuration: +To authenticate with a [personal access token](../../profile/personal_access_tokens.md), +set your NPM configuration: ```bash # Set URL for your scoped packages. @@ -90,7 +125,7 @@ npm config set '//gitlab.com/api/v4/packages/npm/:_authToken' "<your_token>" ``` Replace `<your_project_id>` with your project ID which can be found on the home page -of your project and `<your_token>` with your OAuth or personal access token. +of your project and `<your_token>` with your personal access token. If you have a self-hosted GitLab installation, replace `gitlab.com` with your domain name. @@ -142,9 +177,9 @@ Before you will be able to upload a package, you need to specify the registry for NPM. To do this, add the following section to the bottom of `package.json`: ```json - "publishConfig": { - "@foo:registry":"https://gitlab.com/api/v4/projects/<your_project_id>/packages/npm/" - } +"publishConfig": { + "@foo:registry":"https://gitlab.com/api/v4/projects/<your_project_id>/packages/npm/" +} ``` Replace `<your_project_id>` with your project ID, which can be found on the home @@ -173,6 +208,93 @@ delete the existing package first. This aligns with npmjs.org's behavior, with the exception that npmjs.org does not allow users to ever publish the same version more than once, even if it has been deleted. +## Package naming convention + +**Packages must be scoped in the root namespace of the project**. The package +name may be anything but it is preferred that the project name be used unless +it is not possible due to a naming collision. For example: + +| Project | Package | Supported | +| ---------------------- | ----------------------- | --------- | +| `foo/bar` | `@foo/bar` | Yes | +| `foo/bar/baz` | `@foo/baz` | Yes | +| `foo/bar/buz` | `@foo/anything` | Yes | +| `gitlab-org/gitlab` | `@gitlab-org/gitlab` | Yes | +| `gitlab-org/gitlab` | `@foo/bar` | No | + +The regex that is used for naming is validating all package names from all package managers: + +``` +/\A\@?(([\w\-\.\+]*)\/)*([\w\-\.]+)@?(([\w\-\.\+]*)\/)*([\w\-\.]*)\z/ +``` + +It allows for capital letters, while NPM does not, and allows for almost all of the +characters NPM allows with a few exceptions (`~` is not allowed). + +NOTE: **Note:** Capital letters are needed because the scope is required to be +identical to the top level namespace of the project. So, for example, if your +project path is `My-Group/project-foo`, your package must be named `@My-Group/any-package-name`. +`@my-group/any-package-name` will not work. + +CAUTION: **When updating the path of a user/group or transferring a (sub)group/project:** +If you update the root namespace of a project with NPM packages, your changes will be rejected. To be allowed to do that, make sure to remove any NPM package first. Don't forget to update your `.npmrc` files to follow the above naming convention and run `npm publish` if necessary. + +Now, you can configure your project to authenticate with the GitLab NPM +Registry. + +## Installing a package + +NPM packages are commonly installed using the the `npm` or `yarn` commands +inside a JavaScript project. If you haven't already, you will need to set the +URL for scoped packages. You can do this with the following command: + +```sh +npm config set @foo:registry https://gitlab.com/api/v4/packages/npm/ +``` + +You will need to replace `@foo` with your scope. + +Next, you will need to ensure [authentication](#authenticating-to-the-gitlab-npm-registry) +is setup so you can successfully install the package. Once this has been +completed, you can run the following command inside your project to install a +package: + +```sh +npm install @my-project-scope/my-package +``` + +Or if you're using Yarn: + +```sh +yarn add @my-project-scope/my-package +``` + +## Removing a package + +In the packages view of your project page, you can delete packages by clicking +the red trash icons or by clicking the **Delete** button on the package details +page. + +## Publishing a package with CI/CD + +To work with NPM commands within [GitLab CI](./../../../ci/README.md), you can use +`CI_JOB_TOKEN` in place of the personal access token in your commands. + +A simple example `gitlab-ci.yml` file for publishing NPM packages: + +```yml +image: node:latest + +stages: + - deploy + +deploy: + stage: deploy + script: + - echo '//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=${CI_JOB_TOKEN}'>.npmrc + - npm publish +``` + ## Troubleshooting ### Error running yarn with NPM registry @@ -192,11 +314,11 @@ info If you think this is a bug, please open a bug report with the information p info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command ``` -In this case, try adding this to your `.npmrc` file (and replace `<your_oauth_token>` -with your OAuth or personal access token): +In this case, try adding this to your `.npmrc` file (and replace `<your_token>` +with your personal access token): ```text -//gitlab.com/api/v4/projects/:_authToken=<your_oauth_token> +//gitlab.com/api/v4/projects/:_authToken=<your_token> ``` ### `npm publish` targets default NPM registry (`registry.npmjs.org`) @@ -220,8 +342,8 @@ should look like: And the `.npmrc` file should look like: ```ini -//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=<your_oauth_token> -//gitlab.com/api/v4/packages/npm/:_authToken=<your_oauth_token> +//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=<your_token> +//gitlab.com/api/v4/packages/npm/:_authToken=<your_token> @foo:registry=https://gitlab.com/api/v4/packages/npm/ ``` diff --git a/lib/banzai/filter/repository_link_filter.rb b/lib/banzai/filter/repository_link_filter.rb index 14cd607cc50..d448238c6e4 100644 --- a/lib/banzai/filter/repository_link_filter.rb +++ b/lib/banzai/filter/repository_link_filter.rb @@ -101,11 +101,18 @@ module Banzai def rebuild_relative_uri(uri) file_path = nested_file_path_if_exists(uri) + resource_type = uri_type(file_path) + + # Repository routes are under /-/ scope now. + # Since we craft a path without using route helpers we must + # ensure - is added here. + prefix = '-' if %w(tree blob raw commits).include?(resource_type.to_s) uri.path = [ relative_url_root, project.full_path, - uri_type(file_path), + prefix, + resource_type, Addressable::URI.escape(ref).gsub('#', '%23'), Addressable::URI.escape(file_path) ].compact.join('/').squeeze('/').chomp('/') diff --git a/lib/gitlab/auth/saml/auth_hash.rb b/lib/gitlab/auth/saml/auth_hash.rb index b0df9757bbd..a2b0dfd5c66 100644 --- a/lib/gitlab/auth/saml/auth_hash.rb +++ b/lib/gitlab/auth/saml/auth_hash.rb @@ -28,7 +28,7 @@ module Gitlab end def extract_authn_context(document) - REXML::XPath.first(document, "//*[name()='saml:AuthnStatement' or name()='saml2:AuthnStatement']/*[name()='saml:AuthnContext' or name()='saml2:AuthnContext']/*[name()='saml:AuthnContextClassRef' or name()='saml2:AuthnContextClassRef']/text()").to_s + REXML::XPath.first(document, "//*[name()='saml:AuthnStatement' or name()='saml2:AuthnStatement' or name()='AuthnStatement']/*[name()='saml:AuthnContext' or name()='saml2:AuthnContext' or name()='AuthnContext']/*[name()='saml:AuthnContextClassRef' or name()='saml2:AuthnContextClassRef' or name()='AuthnContextClassRef']/text()").to_s end end end diff --git a/lib/gitlab/ci/pipeline/chain/populate.rb b/lib/gitlab/ci/pipeline/chain/populate.rb index 3a40c7b167c..f9ae37aa273 100644 --- a/lib/gitlab/ci/pipeline/chain/populate.rb +++ b/lib/gitlab/ci/pipeline/chain/populate.rb @@ -17,7 +17,7 @@ module Gitlab # pipeline.stages = @command.stage_seeds.map(&:to_resource) - if pipeline.stages.none? + if stage_names.empty? return error('No stages / jobs for this pipeline.') end @@ -31,6 +31,15 @@ module Gitlab def break? pipeline.errors.any? end + + private + + def stage_names + # We filter out `.pre/.post` stages, as they alone are not considered + # a complete pipeline: + # https://gitlab.com/gitlab-org/gitlab/issues/198518 + pipeline.stages.map(&:name) - ::Gitlab::Ci::Config::EdgeStagesInjector::EDGES + end end end end diff --git a/lib/gitlab/dependency_linker/godeps_json_linker.rb b/lib/gitlab/dependency_linker/godeps_json_linker.rb index d24c137793e..9166e9091ac 100644 --- a/lib/gitlab/dependency_linker/godeps_json_linker.rb +++ b/lib/gitlab/dependency_linker/godeps_json_linker.rb @@ -12,10 +12,12 @@ module Gitlab def link_dependencies link_json('ImportPath') do |path| case path + when %r{\A(?<repo>github\.com/#{REPO_REGEX})/(?<path>.+)\z} + "https://#{$~[:repo]}/tree/master/#{$~[:path]}" when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z}, - %r{\A(?<repo>git(lab|hub)\.com/#{REPO_REGEX})/(?<path>.+)\z} + %r{\A(?<repo>gitlab\.com/#{REPO_REGEX})/(?<path>.+)\z} - "https://#{$~[:repo]}/tree/master/#{$~[:path]}" + "https://#{$~[:repo]}/-/tree/master/#{$~[:path]}" when /\Agolang\.org/ "https://godoc.org/#{path}" else diff --git a/lib/gitlab/middleware/go.rb b/lib/gitlab/middleware/go.rb index f207d91235f..53508938c49 100644 --- a/lib/gitlab/middleware/go.rb +++ b/lib/gitlab/middleware/go.rb @@ -60,7 +60,7 @@ module Gitlab end meta_import_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}" - meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/tree/#{branch}{/dir} #{project_url}/blob/#{branch}{/dir}/{file}#L{line}" + meta_source_tag = tag :meta, name: 'go-source', content: "#{import_prefix} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}" head_tag = content_tag :head, meta_import_tag + meta_source_tag html_tag = content_tag :html, head_tag + body_tag [html_tag, 200] diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 290c4cff329..726ecd81824 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -11,18 +11,26 @@ module Gitlab Error = Class.new(StandardError) class << self + # Retrieve GitLab Shell secret token + # + # @return [String] secret token def secret_token @secret_token ||= begin File.read(Gitlab.config.gitlab_shell.secret_file).chomp end end + # Ensure gitlab shell has a secret token stored in the secret_file + # if that was never generated, generate a new one def ensure_secret_token! return if File.exist?(File.join(Gitlab.config.gitlab_shell.path, '.gitlab_shell_secret')) generate_and_link_secret_token end + # Returns required GitLab shell version + # + # @return [String] version from the manifest file def version_required @version_required ||= File.read(Rails.root .join('GITLAB_SHELL_VERSION')).strip @@ -48,24 +56,31 @@ module Gitlab end end - # Convenience methods for initializing a new repository with a Project model. + # Initialize a new project repository using a Project model + # + # @param [Project] project + # @return [Boolean] whether repository could be created def create_project_repository(project) create_repository(project.repository_storage, project.disk_path, project.full_path) end + # Initialize a new wiki repository using a Project model + # + # @param [Project] project + # @return [Boolean] whether repository could be created def create_wiki_repository(project) create_repository(project.repository_storage, project.wiki.disk_path, project.wiki.full_path) end # Init new repository # - # storage - the shard key - # disk_path - project disk path - # gl_project_path - project name - # - # Ex. + # @example Create a repository # create_repository("default", "path/to/gitlab-ci", "gitlab/gitlab-ci") # + # @param [String] storage the shard key + # @param [String] disk_path project path on disk + # @param [String] gl_project_path project name + # @return [Boolean] whether repository could be created def create_repository(storage, disk_path, gl_project_path) relative_path = disk_path.dup relative_path << '.git' unless relative_path.end_with?('.git') @@ -82,29 +97,39 @@ module Gitlab false end + # Import wiki repository from external service + # + # @param [Project] project + # @param [Gitlab::LegacyGithubImport::WikiFormatter, Gitlab::BitbucketImport::WikiFormatter] wiki_formatter + # @return [Boolean] whether repository could be imported def import_wiki_repository(project, wiki_formatter) import_repository(project.repository_storage, wiki_formatter.disk_path, wiki_formatter.import_url, project.wiki.full_path) end + # Import project repository from external service + # + # @param [Project] project + # @return [Boolean] whether repository could be imported def import_project_repository(project) import_repository(project.repository_storage, project.disk_path, project.import_url, project.full_path) end # Import repository # - # storage - project's storage name - # name - project disk path - # url - URL to import from - # - # Ex. - # import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git") + # @example Import a repository + # import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git", "gitlab/gitlab-ci") # - def import_repository(storage, name, url, gl_project_path) + # @param [String] storage project's storage name + # @param [String] disk_path project path on disk + # @param [String] url from external resource to import from + # @param [String] gl_project_path project name + # @return [Boolean] whether repository could be imported + def import_repository(storage, disk_path, url, gl_project_path) if url.start_with?('.', '/') raise Error.new("don't use disk paths with import_repository: #{url.inspect}") end - relative_path = "#{name}.git" + relative_path = "#{disk_path}.git" cmd = GitalyGitlabProjects.new(storage, relative_path, gl_project_path) success = cmd.import_project(url, git_timeout) @@ -113,27 +138,31 @@ module Gitlab success end - # storage - project's storage path - # path - project disk path - # new_path - new project disk path + # Move or rename a repository # - # Ex. + # @example Move/rename a repository # mv_repository("/path/to/storage", "gitlab/gitlab-ci", "randx/gitlab-ci-new") - def mv_repository(storage, path, new_path) - return false if path.empty? || new_path.empty? + # + # @param [String] storage project's storage path + # @param [String] disk_path current project path on disk + # @param [String] new_disk_path new project path on disk + # @return [Boolean] whether repository could be moved/renamed on disk + def mv_repository(storage, disk_path, new_disk_path) + return false if disk_path.empty? || new_disk_path.empty? - Gitlab::Git::Repository.new(storage, "#{path}.git", nil, nil).rename("#{new_path}.git") + Gitlab::Git::Repository.new(storage, "#{disk_path}.git", nil, nil).rename("#{new_disk_path}.git") true rescue => e - Gitlab::ErrorTracking.track_exception(e, path: path, new_path: new_path, storage: storage) + Gitlab::ErrorTracking.track_exception(e, path: disk_path, new_path: new_disk_path, storage: storage) false end # Fork repository to new path - # source_project - forked-from Project - # target_project - forked-to Project + # + # @param [Project] source_project forked-from Project + # @param [Project] target_project forked-to Project def fork_repository(source_project, target_project) forked_from_relative_path = "#{source_project.disk_path}.git" fork_args = [target_project.repository_storage, "#{target_project.disk_path}.git", target_project.full_path] @@ -145,29 +174,32 @@ module Gitlab # for rm_namespace. Given the underlying implementation removes the name # passed as second argument on the passed storage. # - # storage - project's storage path - # name - project disk path - # - # Ex. + # @example Remove a repository # remove_repository("/path/to/storage", "gitlab/gitlab-ci") - def remove_repository(storage, name) - return false if name.empty? + # + # @param [String] storage project's storage path + # @param [String] disk_path current project path on disk + def remove_repository(storage, disk_path) + return false if disk_path.empty? - Gitlab::Git::Repository.new(storage, "#{name}.git", nil, nil).remove + Gitlab::Git::Repository.new(storage, "#{disk_path}.git", nil, nil).remove true rescue => e - Rails.logger.warn("Repository does not exist: #{e} at: #{name}.git") # rubocop:disable Gitlab/RailsLogger - Gitlab::ErrorTracking.track_exception(e, path: name, storage: storage) + Rails.logger.warn("Repository does not exist: #{e} at: #{disk_path}.git") # rubocop:disable Gitlab/RailsLogger + Gitlab::ErrorTracking.track_exception(e, path: disk_path, storage: storage) false end # Add new key to authorized_keys # - # Ex. + # @example Add new key # add_key("key-42", "sha-rsa ...") # + # @param [String] key_id identifier of the key + # @param [String] key_content key content (public certificate) + # @return [Boolean] whether key could be added def add_key(key_id, key_content) return unless self.authorized_keys_enabled? @@ -176,39 +208,45 @@ module Gitlab # Batch-add keys to authorized_keys # - # Ex. + # @example # batch_add_keys(Key.all) + # + # @param [Array<Key>] keys + # @return [Boolean] whether keys could be added def batch_add_keys(keys) return unless self.authorized_keys_enabled? gitlab_authorized_keys.batch_add_keys(keys) end - # Remove ssh key from authorized_keys + # Remove SSH key from authorized_keys # - # Ex. + # @example Remove a key # remove_key("key-342") # - def remove_key(id, _ = nil) + # @param [String] key_id + # @return [Boolean] whether key could be removed or not + def remove_key(key_id, _ = nil) return unless self.authorized_keys_enabled? - gitlab_authorized_keys.rm_key(id) + gitlab_authorized_keys.rm_key(key_id) end - # Remove all ssh keys from gitlab shell + # Remove all SSH keys from gitlab shell # - # Ex. + # @example Remove all keys # remove_all_keys # + # @return [Boolean] whether keys could be removed or not def remove_all_keys return unless self.authorized_keys_enabled? gitlab_authorized_keys.clear end - # Remove ssh keys from gitlab shell that are not in the DB + # Remove SSH keys from gitlab shell that are not in the DB # - # Ex. + # @example Remove keys not on the database # remove_keys_not_found_in_db # # rubocop: disable CodeReuse/ActiveRecord @@ -234,11 +272,12 @@ module Gitlab # Add empty directory for storing repositories # - # Ex. + # @example Add new namespace directory # add_namespace("default", "gitlab") # + # @param [String] storage project's storage path + # @param [String] name namespace name def add_namespace(storage, name) - # https://gitlab.com/gitlab-org/gitlab-foss/issues/58012 Gitlab::GitalyClient.allow_n_plus_1_calls do Gitlab::GitalyClient::NamespaceService.new(storage).add(name) end @@ -249,9 +288,11 @@ module Gitlab # Remove directory from repositories storage # Every repository inside this directory will be removed too # - # Ex. + # @example Remove namespace directory # rm_namespace("default", "gitlab") # + # @param [String] storage project's storage path + # @param [String] name namespace name def rm_namespace(storage, name) Gitlab::GitalyClient::NamespaceService.new(storage).remove(name) rescue GRPC::InvalidArgument => e @@ -261,9 +302,12 @@ module Gitlab # Move namespace directory inside repositories storage # - # Ex. + # @example Move/rename a namespace directory # mv_namespace("/path/to/storage", "gitlab", "gitlabhq") # + # @param [String] storage project's storage path + # @param [String] old_name current namespace name + # @param [String] new_name new namespace name def mv_namespace(storage, old_name, new_name) Gitlab::GitalyClient::NamespaceService.new(storage).rename(old_name, new_name) rescue GRPC::InvalidArgument => e @@ -272,11 +316,17 @@ module Gitlab false end - def url_to_repo(path) - Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" + # Return a SSH url for a given project path + # + # @param [String] full_path project path (URL) + # @return [String] SSH URL + def url_to_repo(full_path) + Gitlab.config.gitlab_shell.ssh_path_prefix + "#{full_path}.git" end # Return GitLab shell version + # + # @return [String] version def version gitlab_shell_version_file = "#{gitlab_shell_path}/VERSION" @@ -285,12 +335,23 @@ module Gitlab end end + # Check if repository exists on disk + # + # @example Check if repository exists + # repository_exists?('default', 'gitlab-org/gitlab.git') + # + # @return [Boolean] whether repository exists or not + # @param [String] storage project's storage path + # @param [Object] dir_name repository dir name def repository_exists?(storage, dir_name) Gitlab::Git::Repository.new(storage, dir_name, nil, nil).exists? rescue GRPC::Internal false end + # Return hooks folder path used by projects + # + # @return [String] path def hooks_path File.join(gitlab_shell_path, 'hooks') end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 74d7681def3..f44fd8b4cd2 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -10407,15 +10407,9 @@ msgstr "" msgid "Invocations" msgstr "" -msgid "Is" -msgstr "" - msgid "Is blocked by" msgstr "" -msgid "Is not" -msgstr "" - msgid "Is using license seat:" msgstr "" @@ -22464,6 +22458,9 @@ msgstr[1] "" msgid "invalid milestone state `%{state}`" msgstr "" +msgid "is" +msgstr "" + msgid "is an invalid IP address range" msgstr "" @@ -22479,6 +22476,9 @@ msgstr "" msgid "is invalid because there is upstream lock" msgstr "" +msgid "is not" +msgstr "" + msgid "is not a descendant of the Group owning the template" msgstr "" diff --git a/spec/controllers/acme_challenges_controller_spec.rb b/spec/controllers/acme_challenges_controller_spec.rb index cee06bed27b..be077a4b20d 100644 --- a/spec/controllers/acme_challenges_controller_spec.rb +++ b/spec/controllers/acme_challenges_controller_spec.rb @@ -28,7 +28,7 @@ describe AcmeChallengesController do let(:token) { acme_order.challenge_token } it 'renders not found' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -37,7 +37,7 @@ describe AcmeChallengesController do let(:token) { 'wrongtoken' } it 'renders not found' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index ae7b5784302..c1cfe9f20d2 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -156,7 +156,7 @@ describe ApplicationController do it 'returns 200 response' do get :index, format: requested_format - expect(response).to have_gitlab_http_status 200 + expect(response).to have_gitlab_http_status(:ok) end end @@ -164,7 +164,7 @@ describe ApplicationController do it 'returns 404 response' do get :index - expect(response).to have_gitlab_http_status 404 + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -181,7 +181,7 @@ describe ApplicationController do get :index - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'redirects to login page if not authenticated' do @@ -202,7 +202,7 @@ describe ApplicationController do get :index, format: 'unknown' - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -489,7 +489,7 @@ describe ApplicationController do it 'redirects if the user did not accept the terms' do get :index - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end it 'does not redirect when the user accepted terms' do @@ -497,7 +497,7 @@ describe ApplicationController do get :index - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -581,21 +581,21 @@ describe ApplicationController do it 'renders a 404 without a message' do get :index - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response).to render_template('errors/not_found') end it 'renders a 403 when a message is passed to access denied' do get :index, params: { message: 'None shall pass' } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) expect(response).to render_template('errors/access_denied') end it 'renders a status passed to access denied' do get :index, params: { status: 401 } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb index 51f20bae880..1ebbeecc583 100644 --- a/spec/controllers/autocomplete_controller_spec.rb +++ b/spec/controllers/autocomplete_controller_spec.rb @@ -32,7 +32,7 @@ describe AutocompleteController do get(:users, params: { project_id: 'unknown' }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end end @@ -61,7 +61,7 @@ describe AutocompleteController do get(:users, params: { group_id: 'unknown' }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end end @@ -140,7 +140,7 @@ describe AutocompleteController do get(:users, params: { project_id: project.id }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end describe 'GET #users with unknown project' do @@ -148,7 +148,7 @@ describe AutocompleteController do get(:users, params: { project_id: 'unknown' }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end describe 'GET #users with inaccessible group' do @@ -157,7 +157,7 @@ describe AutocompleteController do get(:users, params: { group_id: user.namespace.id }) end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end describe 'GET #users with no project' do @@ -372,7 +372,7 @@ describe AutocompleteController do it 'returns empty json' do get :merge_request_target_branches, params: { project_id: project.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_empty end end @@ -383,7 +383,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: { project_id: project.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_empty end end @@ -404,7 +404,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: params - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response).to eq({ 'error' => 'At least one of group_id or project_id must be specified' }) end end @@ -416,7 +416,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: { project_id: project.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to contain_exactly({ 'title' => 'feature' }) end end @@ -433,7 +433,7 @@ describe AutocompleteController do get :merge_request_target_branches, params: { group_id: group.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to contain_exactly({ 'title' => 'feature' }) end end diff --git a/spec/controllers/chaos_controller_spec.rb b/spec/controllers/chaos_controller_spec.rb index bafd4a70862..5812990ce7a 100644 --- a/spec/controllers/chaos_controller_spec.rb +++ b/spec/controllers/chaos_controller_spec.rb @@ -9,7 +9,7 @@ describe ChaosController do get :leakmem - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'call synchronously with params' do @@ -17,7 +17,7 @@ describe ChaosController do get :leakmem, params: { memory_mb: 1, duration_s: 2 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -25,7 +25,7 @@ describe ChaosController do get :leakmem, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -35,7 +35,7 @@ describe ChaosController do get :cpu_spin - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls synchronously with params' do @@ -43,7 +43,7 @@ describe ChaosController do get :cpu_spin, params: { duration_s: 3 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -51,7 +51,7 @@ describe ChaosController do get :cpu_spin, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -61,7 +61,7 @@ describe ChaosController do get :db_spin - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls synchronously with params' do @@ -69,7 +69,7 @@ describe ChaosController do get :db_spin, params: { duration_s: 4, interval_s: 5 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -77,7 +77,7 @@ describe ChaosController do get :db_spin, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -87,7 +87,7 @@ describe ChaosController do get :sleep - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls synchronously with params' do @@ -95,7 +95,7 @@ describe ChaosController do get :sleep, params: { duration_s: 5 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -103,7 +103,7 @@ describe ChaosController do get :sleep, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -113,7 +113,7 @@ describe ChaosController do get :kill - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'calls asynchronously' do @@ -121,7 +121,7 @@ describe ChaosController do get :kill, params: { async: 1 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/concerns/metrics_dashboard_spec.rb b/spec/controllers/concerns/metrics_dashboard_spec.rb index 389d264bed3..6ab02057412 100644 --- a/spec/controllers/concerns/metrics_dashboard_spec.rb +++ b/spec/controllers/concerns/metrics_dashboard_spec.rb @@ -72,7 +72,7 @@ describe MetricsDashboard do it 'includes project_blob_path only for project dashboards' do expect(system_dashboard['project_blob_path']).to be_nil - expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/blob/master/.gitlab/dashboards/test.yml") + expect(project_dashboard['project_blob_path']).to eq("/#{project.namespace.path}/#{project.name}/-/blob/master/.gitlab/dashboards/test.yml") end describe 'project permissions' do diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 9937bdf4061..0c1089dc7a8 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -39,7 +39,7 @@ describe GraphqlController do it 'returns 200 when user can access API' do post :execute - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns access denied template when user cannot access API' do @@ -59,7 +59,7 @@ describe GraphqlController do it 'returns 200' do post :execute - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 2ed2b319298..3399ad563a1 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -136,7 +136,7 @@ describe GroupsController do get :activity, params: { id: group.to_param }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['count']).to eq(3) expect(assigns(:projects).limit_value).to be_nil end @@ -151,7 +151,7 @@ describe GroupsController do post :create, params: { group: { name: 'new_group', path: "new_group" } } end.to change { Group.count }.by(1) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end context 'authorization' do @@ -162,7 +162,7 @@ describe GroupsController do post :create, params: { group: { name: 'new_group', path: "new_group" } } end.to change { Group.count }.by(1) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -367,7 +367,7 @@ describe GroupsController do it 'updates the path successfully' do post :update, params: { id: group.to_param, group: { path: 'new_path' } } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:notice] end @@ -382,7 +382,7 @@ describe GroupsController do it 'updates the project_creation_level successfully' do post :update, params: { id: group.to_param, group: { project_creation_level: ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS } } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(group.reload.project_creation_level).to eq(::Gitlab::Access::MAINTAINER_PROJECT_ACCESS) end @@ -397,7 +397,7 @@ describe GroupsController do post :update, params: { id: group.to_param, group: { name: 'new_name' } } expect(controller).to set_flash[:notice] - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(group.reload.name).to eq('new_name') end @@ -405,7 +405,7 @@ describe GroupsController do post :update, params: { id: group.to_param, group: { path: 'new_path' } } expect(assigns(:group).errors[:base].first).to match(/Docker images in their Container Registry/) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -468,7 +468,7 @@ describe GroupsController do it 'does not redirect' do get :issues, params: { id: group.to_param } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -487,7 +487,7 @@ describe GroupsController do it 'does not redirect' do get :show, params: { id: group.to_param } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -554,13 +554,13 @@ describe GroupsController do it 'does not 404' do post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -570,7 +570,7 @@ describe GroupsController do it 'returns not found' do post :update, params: { id: redirect_route.path, group: { path: 'new_path' } } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -580,13 +580,13 @@ describe GroupsController do it 'does not 404' do delete :destroy, params: { id: group.to_param.upcase } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do delete :destroy, params: { id: group.to_param.upcase } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -596,7 +596,7 @@ describe GroupsController do it 'returns not found' do delete :destroy, params: { id: redirect_route.path } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -693,7 +693,7 @@ describe GroupsController do end it 'is denied' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -755,13 +755,13 @@ describe GroupsController do it 'is successful' do get :show, params: { id: group.to_param } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'does not allow other formats' do get :show, params: { id: group.to_param }, format: :atom - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -769,7 +769,7 @@ describe GroupsController do it 'is successful' do get :edit, params: { id: group.to_param } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -777,7 +777,7 @@ describe GroupsController do it 'is successful' do get :new - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -786,7 +786,7 @@ describe GroupsController do get :index # Redirects to the dashboard - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -810,7 +810,7 @@ describe GroupsController do it 'deletes the group' do delete :destroy, params: { id: group.to_param } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end diff --git a/spec/controllers/health_check_controller_spec.rb b/spec/controllers/health_check_controller_spec.rb index cbcda5d0dc7..d1de669ad43 100644 --- a/spec/controllers/health_check_controller_spec.rb +++ b/spec/controllers/health_check_controller_spec.rb @@ -101,7 +101,7 @@ describe HealthCheckController, :request_store do it 'supports failure plaintext response' do get :index - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'text/plain' expect(response.body).to include('The server is on fire') end @@ -109,7 +109,7 @@ describe HealthCheckController, :request_store do it 'supports failure json response' do get :index, format: :json - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'application/json' expect(json_response['healthy']).to be false expect(json_response['message']).to include('The server is on fire') @@ -118,7 +118,7 @@ describe HealthCheckController, :request_store do it 'supports failure xml response' do get :index, format: :xml - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'application/xml' expect(xml_response['healthy']).to be false expect(xml_response['message']).to include('The server is on fire') @@ -127,7 +127,7 @@ describe HealthCheckController, :request_store do it 'supports failure responses for specific checks' do get :index, params: { checks: 'email' }, format: :json - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.content_type).to eq 'application/json' expect(json_response['healthy']).to be false expect(json_response['message']).to include('Email is on fire') diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index 03b6e85b653..69b5605c0e5 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -148,7 +148,7 @@ describe HelpController do context 'for UI Development Kit' do it 'renders found' do get :ui - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index ac0adcd06a3..9daaa258aa2 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -17,7 +17,7 @@ describe InvitesController do get :accept, params: { id: token } member.reload - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(member.user).to eq(user) expect(flash[:notice]).to include 'You have been granted' end @@ -28,7 +28,7 @@ describe InvitesController do get :decline, params: { id: token } expect {member.reload}.to raise_error ActiveRecord::RecordNotFound - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(flash[:notice]).to include 'You have declined the invitation to join' end end diff --git a/spec/controllers/notification_settings_controller_spec.rb b/spec/controllers/notification_settings_controller_spec.rb index 46328148eff..7b19c67cad3 100644 --- a/spec/controllers/notification_settings_controller_spec.rb +++ b/spec/controllers/notification_settings_controller_spec.rb @@ -125,7 +125,7 @@ describe NotificationSettingsController do notification_setting: { level: :participating } } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -195,7 +195,7 @@ describe NotificationSettingsController do notification_setting: { level: :participating } } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/omniauth_callbacks_controller_spec.rb b/spec/controllers/omniauth_callbacks_controller_spec.rb index 8b92976252c..71cdba12147 100644 --- a/spec/controllers/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/omniauth_callbacks_controller_spec.rb @@ -172,7 +172,7 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode: it 'returns 403' do post provider - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index bf9680329ce..3ec8e347659 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -15,7 +15,7 @@ describe PasswordsController do post :create - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(flash[:alert]).to eq _('Password authentication is unavailable.') end end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 265f941e146..91f3bfcfa40 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -87,7 +87,7 @@ describe ProfilesController, :request_store do put :update, params: { user: { status: { message: 'Working hard!' } } } expect(user.reload.status.message).to eq('Working hard!') - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end diff --git a/spec/controllers/projects/blame_controller_spec.rb b/spec/controllers/projects/blame_controller_spec.rb index dd7c0f45dc2..ac8394e3cd4 100644 --- a/spec/controllers/projects/blame_controller_spec.rb +++ b/spec/controllers/projects/blame_controller_spec.rb @@ -36,7 +36,7 @@ describe Projects::BlameController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") end end diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 78599935910..aa1dcdd9f1d 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -33,7 +33,7 @@ describe Projects::BlobController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") end end @@ -115,7 +115,7 @@ describe Projects::BlobController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/markdown/doc") + .to redirect_to("/#{project.full_path}/-/tree/markdown/doc") end end end diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index ac39ac626c7..5b59534cb49 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -38,7 +38,7 @@ describe Projects::BranchesController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/merge_branch") + .to redirect_to("/#{project.full_path}/-/tree/merge_branch") end end @@ -48,7 +48,7 @@ describe Projects::BranchesController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/alert('merge');") + .to redirect_to("/#{project.full_path}/-/tree/alert('merge');") end end @@ -93,7 +93,7 @@ describe Projects::BranchesController do } expect(subject) - .to redirect_to("/#{project.full_path}/tree/1-feature-branch") + .to redirect_to("/#{project.full_path}/-/tree/1-feature-branch") end it 'posts a system note' do diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb index a570db12d94..aef8ef1d487 100644 --- a/spec/controllers/projects/raw_controller_spec.rb +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -72,7 +72,7 @@ describe Projects::RawController do env: :raw_blob_request_limit, remote_ip: '0.0.0.0', request_method: 'GET', - path: "/#{project.full_path}/raw/#{file_path}" + path: "/#{project.full_path}/-/raw/#{file_path}" } expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 7c9abdf700b..5df05a06f00 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -45,7 +45,7 @@ describe Projects::TreeController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") end end @@ -60,7 +60,7 @@ describe Projects::TreeController do it 'redirects' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/empty-branch") + .to redirect_to("/#{project.full_path}/-/tree/empty-branch") end end @@ -153,7 +153,7 @@ describe Projects::TreeController do let(:id) { 'master/README.md' } it 'redirects' do - redirect_url = "/#{project.full_path}/blob/master/README.md" + redirect_url = "/#{project.full_path}/-/blob/master/README.md" expect(subject) .to redirect_to(redirect_url) end @@ -181,7 +181,7 @@ describe Projects::TreeController do it 'redirects to the new directory' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/#{branch_name}/#{path}") + .to redirect_to("/#{project.full_path}/-/tree/#{branch_name}/#{path}") expect(flash[:notice]).to eq('The directory has been successfully created.') end end @@ -192,7 +192,7 @@ describe Projects::TreeController do it 'does not allow overwriting of existing files' do expect(subject) - .to redirect_to("/#{project.full_path}/tree/master") + .to redirect_to("/#{project.full_path}/-/tree/master") expect(flash[:alert]).to eq('A file with this name already exists') end end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 9ae1277de26..a44218a5d2f 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -27,7 +27,7 @@ describe ProjectsController do get :new, params: { namespace_id: group.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('new') end end @@ -36,7 +36,7 @@ describe ProjectsController do it 'responds with status 404' do get :new, params: { namespace_id: group.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response).not_to render_template('new') end end @@ -159,7 +159,7 @@ describe ProjectsController do it 'renders a 503' do get :show, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(503) + expect(response).to have_gitlab_http_status(:service_unavailable) end end @@ -264,7 +264,7 @@ describe ProjectsController do get :show, params: { namespace_id: project.namespace, id: project }, format: :git - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_path) end end @@ -331,7 +331,7 @@ describe ProjectsController do id: project.path } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'sets the badge API endpoint' do @@ -371,7 +371,7 @@ describe ProjectsController do end it 'redirects to projects path' do - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(project_path(project)) end end @@ -391,7 +391,7 @@ describe ProjectsController do end it 'returns 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -419,7 +419,7 @@ describe ProjectsController do end it 'redirects to projects path' do - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(project_path(project)) end end @@ -439,7 +439,7 @@ describe ProjectsController do end it 'returns 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -466,7 +466,7 @@ describe ProjectsController do id: project.path } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -486,7 +486,7 @@ describe ProjectsController do id: project.path } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -521,7 +521,7 @@ describe ProjectsController do expect(assign_repository_path).to include(project.path) end - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -537,7 +537,7 @@ describe ProjectsController do .not_to change { project.reload.path } expect(controller).to set_flash.now[:alert].to(s_('UpdateProject|Cannot rename project because it contains container registry tags!')) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -555,7 +555,7 @@ describe ProjectsController do project: params } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) params.each do |param, value| expect(project.public_send(param)).to eq(value) end @@ -653,7 +653,7 @@ describe ProjectsController do project.reload expect(project.namespace).to eq(new_namespace) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'when new namespace is empty' do @@ -674,7 +674,7 @@ describe ProjectsController do project.reload expect(project.namespace).to eq(old_namespace) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(flash[:alert]).to eq s_('TransferProject|Please select a new namespace for your project.') end end @@ -691,7 +691,7 @@ describe ProjectsController do delete :destroy, params: { namespace_id: project.namespace, id: project } expect { Project.find(orig_id) }.to raise_error(ActiveRecord::RecordNotFound) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(dashboard_projects_path) end @@ -733,7 +733,7 @@ describe ProjectsController do end it 'has http status 200' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'changes the user incoming email token' do @@ -763,7 +763,7 @@ describe ProjectsController do end it 'has http status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'changes the user incoming email token' do @@ -856,7 +856,7 @@ describe ProjectsController do id: project }, format: :js) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -905,7 +905,7 @@ describe ProjectsController do sign_in(user) get :refs, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -928,7 +928,7 @@ describe ProjectsController do it 'returns 404' do post :preview_markdown, params: { namespace_id: private_project.namespace, id: private_project, text: '*Markdown* text' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -973,7 +973,7 @@ describe ProjectsController do end it 'renders JSON body with image links expanded' do - expanded_path = "/#{project_with_repo.full_path}/raw/master/files/images/logo-white.png" + expanded_path = "/#{project_with_repo.full_path}/-/raw/master/files/images/logo-white.png" post :preview_markdown, params: preview_markdown_params @@ -994,7 +994,7 @@ describe ProjectsController do get :show, params: { namespace_id: public_project.namespace, id: public_project } expect(assigns(:project)).to eq(public_project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -1033,13 +1033,13 @@ describe ProjectsController do it 'does not 404' do post :toggle_star, params: { namespace_id: public_project.namespace, id: public_project.path.upcase } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do post :toggle_star, params: { namespace_id: public_project.namespace, id: public_project.path.upcase } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -1049,7 +1049,7 @@ describe ProjectsController do it 'returns not found' do post :toggle_star, params: { namespace_id: 'foo', id: 'bar' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -1063,13 +1063,13 @@ describe ProjectsController do it 'does not 404' do delete :destroy, params: { namespace_id: project.namespace, id: project.path.upcase } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do delete :destroy, params: { namespace_id: project.namespace, id: project.path.upcase } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -1079,7 +1079,7 @@ describe ProjectsController do it 'returns not found' do delete :destroy, params: { namespace_id: 'foo', id: 'bar' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -1103,7 +1103,7 @@ describe ProjectsController do get action, params: { namespace_id: project.namespace, id: project } expect(flash[:alert]).to eq('This endpoint has been requested too many times. Try again later.') - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1114,7 +1114,7 @@ describe ProjectsController do it 'returns 302' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1126,7 +1126,7 @@ describe ProjectsController do it 'returns 404' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1143,7 +1143,7 @@ describe ProjectsController do it 'returns 302' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1155,7 +1155,7 @@ describe ProjectsController do it 'returns 404' do get action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1172,7 +1172,7 @@ describe ProjectsController do it 'returns 302' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1184,7 +1184,7 @@ describe ProjectsController do it 'returns 404' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -1196,7 +1196,7 @@ describe ProjectsController do it 'returns 302' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -1208,7 +1208,7 @@ describe ProjectsController do it 'returns 404' do post action, params: { namespace_id: project.namespace, id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1245,7 +1245,7 @@ describe ProjectsController do it 'redirects to the project page' do get :resolve, params: { id: project.id } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(project_path(project)) end end @@ -1267,14 +1267,14 @@ describe ProjectsController do it 'gives 404 for existing project' do get :resolve, params: { id: project.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end it 'gives 404 for non-existing project' do get :resolve, params: { id: '0' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1288,7 +1288,7 @@ describe ProjectsController do it 'gives 404 for private project' do get :resolve, params: { id: project.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 214eb35ec9d..792219d830d 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -30,7 +30,7 @@ describe RegistrationsController do it 'renders new template and sets the resource variable' do expect(subject).to render_template(:new) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:resource)).to be_a(User) end end @@ -48,7 +48,7 @@ describe RegistrationsController do it 'renders new template and sets the resource variable' do subject - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane')) end end @@ -200,7 +200,7 @@ describe RegistrationsController do .and_call_original expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to be_empty end end diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index ca7b8a4036a..19786417d76 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -21,13 +21,13 @@ describe SearchController do it 'blocks access without a project_id' do get action, params: params - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'allows access with a project_id' do get action, params: params.merge(project_id: create(:project, :public).id) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -42,13 +42,13 @@ describe SearchController do it 'renders a 403 when no project is given' do get action, params: params - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'renders a 200 when a project was set' do get action, params: params.merge(project_id: project.id) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -57,7 +57,7 @@ describe SearchController do it 'still allows accessing the search page' do get :show - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -195,7 +195,7 @@ describe SearchController do get :count, params: { search: 'hello', scope: 'projects' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq({ 'count' => '1' }) end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 1e47df150b4..63797e22b38 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -22,7 +22,7 @@ describe SessionsController do it 'redirects to :omniauth_authorize_path' do get(:new) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to('/saml') end end @@ -31,7 +31,7 @@ describe SessionsController do it 'responds with 200' do get(:new, params: { auto_sign_in: 'false' }) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index c8f9e4256c9..f8fc9a72e00 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -51,7 +51,7 @@ describe SnippetsController do it 'responds with status 200' do get :new - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'when user is not allowed to create a personal snippet' do @@ -60,7 +60,7 @@ describe SnippetsController do it 'responds with status 404' do get :new - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -90,7 +90,7 @@ describe SnippetsController do it 'responds with status 404' do get :show, params: { id: other_personal_snippet.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -99,13 +99,13 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'responds with status 404 when embeddable content is requested' do get :show, params: { id: personal_snippet.to_param }, format: :js - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -131,13 +131,13 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'responds with status 404 when embeddable content is requested' do get :show, params: { id: personal_snippet.to_param }, format: :js - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -162,14 +162,14 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'responds with status 200 when embeddable content is requested' do get :show, params: { id: personal_snippet.to_param }, format: :js expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -178,7 +178,7 @@ describe SnippetsController do get :show, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -192,7 +192,7 @@ describe SnippetsController do it 'responds with status 404' do get :show, params: { id: 'doesntexist' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -234,7 +234,7 @@ describe SnippetsController do create_snippet(visibility_level: Snippet::PUBLIC) end.not_to change { Snippet.count } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -496,7 +496,7 @@ describe SnippetsController do it 'responds with status 404' do get :raw, params: { id: other_personal_snippet.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -507,7 +507,7 @@ describe SnippetsController do it 'responds with status 200' do expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'has expected headers' do @@ -517,7 +517,7 @@ describe SnippetsController do end it "sets #{Gitlab::Workhorse::DETECT_HEADER} header" do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" end end @@ -544,7 +544,7 @@ describe SnippetsController do get :raw, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -569,7 +569,7 @@ describe SnippetsController do get :raw, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'CRLF line ending' do @@ -596,7 +596,7 @@ describe SnippetsController do get :raw, params: { id: personal_snippet.to_param } expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -610,7 +610,7 @@ describe SnippetsController do it 'responds with status 404' do get :raw, params: { id: 'doesntexist' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -712,7 +712,7 @@ describe SnippetsController do it 'responds with status 404' do delete :destroy, params: { id: snippet.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index ff15e685007..69e2c085659 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -46,7 +46,7 @@ describe UploadsController do it "returns 401 when the user is not logged in" do post :create, params: { model: model, id: snippet.id }, format: :json - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it "returns 404 when user can't comment on a snippet" do @@ -55,7 +55,7 @@ describe UploadsController do sign_in(user) post :create, params: { model: model, id: private_snippet.id }, format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -67,7 +67,7 @@ describe UploadsController do it "returns an error without file" do post :create, params: { model: model, id: snippet.id }, format: :json - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end it "returns an error with invalid model" do @@ -78,7 +78,7 @@ describe UploadsController do it "returns 404 status when object not found" do post :create, params: { model: model, id: 9999 }, format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context 'with valid image' do @@ -129,7 +129,7 @@ describe UploadsController do it 'returns 401 when the user has no access' do post :create, params: { model: 'user', id: user.id }, format: :json - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end context 'when user is logged in' do @@ -188,7 +188,7 @@ describe UploadsController do post :create, params: { model: model, id: another_user.id, file: txt }, format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -246,7 +246,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -254,7 +254,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -271,7 +271,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -296,7 +296,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -316,7 +316,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -338,7 +338,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -361,7 +361,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -369,7 +369,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -386,7 +386,7 @@ describe UploadsController do it "responds with status 404" do get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -401,7 +401,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -421,7 +421,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -457,7 +457,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -465,7 +465,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content 5 min private cached with revalidation' do @@ -482,7 +482,7 @@ describe UploadsController do it "responds with status 404" do get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -502,7 +502,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content not cached' do @@ -522,7 +522,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content not cached' do @@ -544,7 +544,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -567,7 +567,7 @@ describe UploadsController do it "responds with status 401" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -575,7 +575,7 @@ describe UploadsController do it "responds with status 200" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content not cached' do @@ -592,7 +592,7 @@ describe UploadsController do it "responds with status 404" do get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -607,7 +607,7 @@ describe UploadsController do it 'responds with status 200' do get :show, params: { model: 'appearance', mounted_as: 'header_logo', id: appearance.id, filename: 'dk.png' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -627,7 +627,7 @@ describe UploadsController do it 'responds with status 200' do get :show, params: { model: 'appearance', mounted_as: 'logo', id: appearance.id, filename: 'dk.png' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it_behaves_like 'content publicly cached' do @@ -648,7 +648,7 @@ describe UploadsController do it 'successfully returns the file' do get :show, params: { model: 'appearance', mounted_as: 'favicon', id: appearance.id, filename: 'dk.png' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['Content-Disposition']).to end_with 'filename="dk.png"' end end @@ -657,7 +657,7 @@ describe UploadsController do it 'returns a 404' do get :show, params: { model: 'appearance', mounted_as: 'favicon', id: appearance.id, filename: 'bogus.png' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 597d2a185b5..2af398e143d 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -28,7 +28,7 @@ describe UsersController do it 'renders the show template' do get :show, params: { username: user.username } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end end @@ -53,7 +53,7 @@ describe UsersController do it 'renders show' do get :show, params: { username: user.username } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end end @@ -74,7 +74,7 @@ describe UsersController do it 'renders 404' do get :show, params: { username: 'nonexistent' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -130,7 +130,7 @@ describe UsersController do get :calendar, params: { username: public_user.username }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -285,7 +285,7 @@ describe UsersController do context 'format html' do it 'renders snippets page' do get :snippets, params: { username: user.username } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end end @@ -293,7 +293,7 @@ describe UsersController do context 'format json' do it 'response with snippets json data' do get :snippets, params: { username: user.username }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to have_key('html') end end diff --git a/spec/fixtures/authentication/adfs_saml_response.xml b/spec/fixtures/authentication/adfs_saml_response.xml new file mode 100644 index 00000000000..1056d73638c --- /dev/null +++ b/spec/fixtures/authentication/adfs_saml_response.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="jVFQbyEpSfUwqhZtJtarIaGoshwuAQMDwLoiMhzJXsv" Version="2.0" IssueInstant="2020-01-23T06:12:41.896Z" Destination="https://gitlab-example.com/users/auth/saml/callback" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" InResponseTo="feooghajnhofcmogakmlhpkohnmikicnfhdnjlc"> + <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://example.com/adfs/services/trust</Issuer> + <samlp:Status> + <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/> + </samlp:Status> + <Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="emmCjammnYdAbMWDuMAJeZvQIMBayeeYqqwvQoDclKE" IssueInstant="2020-01-23T06:12:41.896Z" Version="2.0"> + <Issuer>https://example.com/adfs/services/trust</Issuer> + <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> + <ds:SignedInfo> + <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> + <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> + <ds:Reference URI="#jVFQbyEpSfUwqhZtJtarIaGoshwuAQMDwLoiMhzJXsv"> + <ds:Transforms> + <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> + <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> + </ds:Transforms> + <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> + <ds:DigestValue>uHuSry39P16Yh7srS32xESmj4Lw</ds:DigestValue> + </ds:Reference> + </ds:SignedInfo> + <ds:SignatureValue>fdghdfggfd=</ds:SignatureValue> + <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> + <ds:X509Data> + <ds:X509Certificate>dfghjkl</ds:X509Certificate> + </ds:X509Data> + </KeyInfo> + </ds:Signature> + <Subject> + <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">example@example.com</NameID> + <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> + <SubjectConfirmationData InResponseTo="cfeooghajnhofcmogakmlhpkohnmikicnfhdnjlc" NotOnOrAfter="2020-01-23T06:17:41.896Z" Recipient="https://gitlab-example.com/users/auth/saml/callback"/> + </SubjectConfirmation> + </Subject> + <Conditions NotBefore="2020-01-23T06:10:41.818Z" NotOnOrAfter="2020-01-23T07:10:41.818Z"> + <AudienceRestriction> + <Audience>https://gitlab-example.com</Audience> + </AudienceRestriction> + </Conditions> + <AttributeStatement> + <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"> + <AttributeValue>example@example.com</AttributeValue> + </Attribute> + <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"> + <AttributeValue>Example User</AttributeValue> + </Attribute> + <Attribute Name="http://schemas.xmlsoap.org/claims/Group"> + <AttributeValue>Group 1</AttributeValue> + <AttributeValue>Another Group</AttributeValue> + </Attribute> + </AttributeStatement> + <AuthnStatement AuthnInstant="2020-01-23T06:12:41.756Z" SessionIndex="perdkjfskdjfksdiertusfsdfsddeurtherukjdfgkdffg"> + <AuthnContext> + <AuthnContextClassRef>urn:federation:authentication:windows</AuthnContextClassRef> + </AuthnContext> + </AuthnStatement> + </Assertion> +</samlp:Response> diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js index d676d7539b6..83a3cfe618b 100644 --- a/spec/frontend/ide/services/index_spec.js +++ b/spec/frontend/ide/services/index_spec.js @@ -97,7 +97,7 @@ describe('IDE services', () => { mock .onGet( - `${relativeUrlRoot}/${TEST_PROJECT_ID}/raw/${TEST_COMMIT_SHA}/${escapeFileUrl( + `${relativeUrlRoot}/${TEST_PROJECT_ID}/-/raw/${TEST_COMMIT_SHA}/${escapeFileUrl( filePath, )}`, ) diff --git a/spec/frontend/repository/components/table/parent_row_spec.js b/spec/frontend/repository/components/table/parent_row_spec.js index 439c7ff080c..360c2e97353 100644 --- a/spec/frontend/repository/components/table/parent_row_spec.js +++ b/spec/frontend/repository/components/table/parent_row_spec.js @@ -32,8 +32,8 @@ describe('Repository parent row component', () => { it.each` path | to - ${'app'} | ${'/tree/master/'} - ${'app/assets'} | ${'/tree/master/app'} + ${'app'} | ${'/-/tree/master/'} + ${'app/assets'} | ${'/-/tree/master/app'} `('renders link in $path to $to', ({ path, to }) => { factory(path); @@ -48,7 +48,7 @@ describe('Repository parent row component', () => { vm.find('td').trigger('click'); expect($router.push).toHaveBeenCalledWith({ - path: '/tree/master/app', + path: '/-/tree/master/app', }); }); @@ -60,7 +60,7 @@ describe('Repository parent row component', () => { vm.find('a').trigger('click'); expect($router.push).not.toHaveBeenCalledWith({ - path: '/tree/master/app', + path: '/-/tree/master/app', }); }); diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index b60560366a6..b0c97dee414 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -88,7 +88,7 @@ describe('Repository table row component', () => { vm.trigger('click'); if (pushes) { - expect($router.push).toHaveBeenCalledWith({ path: '/tree/master/test' }); + expect($router.push).toHaveBeenCalledWith({ path: '/-/tree/master/test' }); } else { expect($router.push).not.toHaveBeenCalled(); } diff --git a/spec/frontend/repository/router_spec.js b/spec/frontend/repository/router_spec.js index f61a0ccd1e6..1efd74a30c2 100644 --- a/spec/frontend/repository/router_spec.js +++ b/spec/frontend/repository/router_spec.js @@ -4,11 +4,11 @@ import createRouter from '~/repository/router'; describe('Repository router spec', () => { it.each` - path | component | componentName - ${'/'} | ${IndexPage} | ${'IndexPage'} - ${'/tree/master'} | ${TreePage} | ${'TreePage'} - ${'/tree/master/app/assets'} | ${TreePage} | ${'TreePage'} - ${'/tree/123/app/assets'} | ${null} | ${'null'} + path | component | componentName + ${'/'} | ${IndexPage} | ${'IndexPage'} + ${'/-/tree/master'} | ${TreePage} | ${'TreePage'} + ${'/-/tree/master/app/assets'} | ${TreePage} | ${'TreePage'} + ${'/-/tree/123/app/assets'} | ${null} | ${'null'} `('sets component as $componentName for path "$path"', ({ path, component }) => { const router = createRouter('', 'master'); diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 4996e27c2e6..2d0c4723648 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -56,7 +56,7 @@ describe BlobHelper do stub_feature_flags(web_ide_default: false) link = helper.edit_blob_button(project, 'master', 'README.md') - expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md") + expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md") end it 'returns a link with a Web IDE route' do @@ -69,7 +69,7 @@ describe BlobHelper do stub_feature_flags(web_ide_default: false) link = helper.edit_blob_button(project, 'master', 'README.md', link_opts: { mr_id: 10 }) - expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md?mr_id=10") + expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/-/edit/master/README.md?mr_id=10") end end diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index 2f91ab3afb3..89730a67977 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -103,7 +103,7 @@ describe MarkupHelper do let(:requested_path) { 'files/images/README.md' } it 'returns the correct HTML for the image' do - expanded_path = "/#{project.full_path}/raw/master/files/images/#{image_file}" + expanded_path = "/#{project.full_path}/-/raw/master/files/images/#{image_file}" expect(subject.css('a')[0].attr('href')).to eq(expanded_path) expect(subject.css('img')[0].attr('data-src')).to eq(expanded_path) diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb index 8eb40b5975a..d229753a0f0 100644 --- a/spec/helpers/submodule_helper_spec.rb +++ b/spec/helpers/submodule_helper_spec.rb @@ -100,34 +100,34 @@ describe SubmoduleHelper do allow(repo).to receive(:project).and_return(project) stub_url('./') - expect(subject).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"]) + expect(subject).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/-/tree/hash"]) end end context 'submodule on gitlab.com' do it 'detects ssh' do stub_url('git@gitlab.com:gitlab-org/gitlab-foss.git') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'detects http' do stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'detects https' do stub_url('https://gitlab.com/gitlab-org/gitlab-foss.git') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'handles urls with no .git on the end' do stub_url('http://gitlab.com/gitlab-org/gitlab-foss') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'handles urls with trailing whitespace' do stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git ') - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end it 'returns original with non-standard url' do @@ -171,7 +171,7 @@ describe SubmoduleHelper do stub_url(relative_path) result = subject - expect(result).to eq([expected_path, "#{expected_path}/tree/#{submodule_item.id}"]) + expect(result).to eq([expected_path, "#{expected_path}/-/tree/#{submodule_item.id}"]) end it 'handles project under same group' do diff --git a/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js b/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js index c743f1f6ad7..6a83790093a 100644 --- a/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js +++ b/spec/javascripts/vue_shared/components/diff_viewer/diff_viewer_spec.js @@ -38,11 +38,11 @@ describe('DiffViewer', () => { setTimeout(() => { expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe( - `//raw/DEF/${RED_BOX_IMAGE_URL}`, + `//-/raw/DEF/${RED_BOX_IMAGE_URL}`, ); expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe( - `//raw/ABC/${GREEN_BOX_IMAGE_URL}`, + `//-/raw/ABC/${GREEN_BOX_IMAGE_URL}`, ); done(); diff --git a/spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js b/spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js deleted file mode 100644 index 9e72a0e2480..00000000000 --- a/spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js +++ /dev/null @@ -1,73 +0,0 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; -import GraphqlPagination from '~/vue_shared/components/pagination/graphql_pagination.vue'; - -const localVue = createLocalVue(); - -describe('Graphql Pagination component', () => { - let wrapper; - function factory({ hasNextPage = true, hasPreviousPage = true }) { - wrapper = shallowMount(localVue.extend(GraphqlPagination), { - propsData: { - hasNextPage, - hasPreviousPage, - }, - localVue, - }); - } - - afterEach(() => { - wrapper.destroy(); - }); - - describe('without previous page', () => { - beforeEach(() => { - factory({ hasPreviousPage: false }); - }); - - it('renders disabled previous button', () => { - expect(wrapper.find('.js-prev-btn').attributes().disabled).toEqual('true'); - }); - }); - - describe('with previous page', () => { - beforeEach(() => { - factory({ hasPreviousPage: true }); - }); - - it('renders enabled previous button', () => { - expect(wrapper.find('.js-prev-btn').attributes().disabled).toEqual(undefined); - }); - - it('emits previousClicked on click', () => { - wrapper.find('.js-prev-btn').vm.$emit('click'); - - expect(wrapper.emitted().previousClicked.length).toBe(1); - }); - }); - - describe('without next page', () => { - beforeEach(() => { - factory({ hasNextPage: false }); - }); - - it('renders disabled next button', () => { - expect(wrapper.find('.js-next-btn').attributes().disabled).toEqual('true'); - }); - }); - - describe('with next page', () => { - beforeEach(() => { - factory({ hasNextPage: true }); - }); - - it('renders enabled next button', () => { - expect(wrapper.find('.js-next-btn').attributes().disabled).toEqual(undefined); - }); - - it('emits nextClicked on click', () => { - wrapper.find('.js-next-btn').vm.$emit('click'); - - expect(wrapper.emitted().nextClicked.length).toBe(1); - }); - }); -}); diff --git a/spec/lib/banzai/filter/repository_link_filter_spec.rb b/spec/lib/banzai/filter/repository_link_filter_spec.rb index 6945973dfd6..cf73c77ecb8 100644 --- a/spec/lib/banzai/filter/repository_link_filter_spec.rb +++ b/spec/lib/banzai/filter/repository_link_filter_spec.rb @@ -152,7 +152,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds absolute URL for a file in the repo' do doc = filter(link('/doc/api/README.md')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'does not modify relative URLs in system notes' do @@ -170,13 +170,13 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds relative URL for a file in the repo' do doc = filter(link('doc/api/README.md')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo with leading ./' do doc = filter(link('./doc/api/README.md')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up one directory' do @@ -184,7 +184,7 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md') expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up multiple directories' do @@ -192,7 +192,7 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md') expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repository root' do @@ -200,47 +200,47 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(relative_link, requested_path: 'doc/some-file.md') expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md" + .to eq "/#{project_path}/-/blob/#{ref}/README.md" end it 'rebuilds relative URL for a file in the repo with an anchor' do doc = filter(link('README.md#section')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md#section" + .to eq "/#{project_path}/-/blob/#{ref}/README.md#section" end it 'rebuilds relative URL for a directory in the repo' do doc = filter(link('doc/api/')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/tree/#{ref}/doc/api" + .to eq "/#{project_path}/-/tree/#{ref}/doc/api" end it 'rebuilds relative URL for an image in the repo' do doc = filter(image('files/images/logo-black.png')) expect(doc.at_css('img')['src']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + .to eq "/#{project_path}/-/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for link to an image in the repo' do doc = filter(link('files/images/logo-black.png')) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + .to eq "/#{project_path}/-/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for a video in the repo' do doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video') expect(doc.at_css('video')['src']) - .to eq "/#{project_path}/raw/video/files/videos/intro.mp4" + .to eq "/#{project_path}/-/raw/video/files/videos/intro.mp4" end it 'rebuilds relative URL for audio in the repo' do doc = filter(audio('files/audio/sample.wav'), commit: project.commit('audio'), ref: 'audio') expect(doc.at_css('audio')['src']) - .to eq "/#{project_path}/raw/audio/files/audio/sample.wav" + .to eq "/#{project_path}/-/raw/audio/files/audio/sample.wav" end it 'does not modify relative URL with an anchor only' do @@ -267,7 +267,7 @@ describe Banzai::Filter::RepositoryLinkFilter do allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw) doc = filter(image(escaped)) - expect(doc.at_css('img')['src']).to eq "/#{project_path}/raw/#{Addressable::URI.escape(ref)}/#{escaped}" + expect(doc.at_css('img')['src']).to eq "/#{project_path}/-/raw/#{Addressable::URI.escape(ref)}/#{escaped}" end context 'when requested path is a file in the repo' do @@ -275,7 +275,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds URL relative to the containing directory' do doc = filter(link('users.md')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" end end @@ -284,7 +284,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'rebuilds URL relative to the directory' do doc = filter(link('users.md')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" end end @@ -295,7 +295,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'correctly escapes the ref' do doc = filter(link('.gitkeep')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep" end end @@ -314,7 +314,7 @@ describe Banzai::Filter::RepositoryLinkFilter do doc = filter(link(path)) expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/raw/#{ref_escaped}/files/images/logo-black.png" + .to eq "/#{project_path}/-/raw/#{ref_escaped}/files/images/logo-black.png" end end @@ -325,7 +325,7 @@ describe Banzai::Filter::RepositoryLinkFilter do it 'does not escape the space twice' do doc = filter(link('README.md')) - expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md" + expect(doc.at_css('a')['href']).to eq "/#{project_path}/-/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md" end end end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 861ef79b2f8..ef9929a9dce 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -31,7 +31,7 @@ describe ExtractsPath do it "log tree path has no escape sequences" do assign_ref_vars - expect(@logs_path).to eq("/#{@project.full_path}/refs/#{ref}/logs_tree/files/ruby/popen.rb") + expect(@logs_path).to eq("/#{@project.full_path}/-/refs/#{ref}/logs_tree/files/ruby/popen.rb") end context 'ref contains %20' do diff --git a/spec/lib/gitlab/auth/saml/auth_hash_spec.rb b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb index 13636a495d1..8b88c16f317 100644 --- a/spec/lib/gitlab/auth/saml/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb @@ -95,6 +95,17 @@ describe Gitlab::Auth::Saml::AuthHash do end end + context 'with ADFS SAML response_object' do + before do + auth_hash_data[:extra][:response_object] = { document: + saml_xml(File.read('spec/fixtures/authentication/adfs_saml_response.xml')) } + end + + it 'can extract authn_context' do + expect(saml_auth_hash.authn_context).to eq 'urn:federation:authentication:windows' + end + end + context 'without response_object' do it 'returns an empty string' do expect(saml_auth_hash.authn_context).to be_nil diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index adf5a232a75..7ecc42ea497 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -258,7 +258,7 @@ FILE describe '#as_json' do it 'includes the blob path for the file' do expect(conflict_file.as_json[:blob_path]) - .to eq("/#{project.full_path}/blob/#{our_commit.oid}/files/ruby/regex.rb") + .to eq("/#{project.full_path}/-/blob/#{our_commit.oid}/files/ruby/regex.rb") end it 'includes the blob icon for the file' do diff --git a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb index 9f8542a76c9..7128689e362 100644 --- a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb +++ b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb @@ -75,8 +75,8 @@ describe Gitlab::DependencyLinker::GodepsJsonLinker do end it 'links GitLab projects' do - expect(subject).to include(link('gitlab.com/group/project/path', 'https://gitlab.com/group/project/tree/master/path')) - expect(subject).to include(link('gitlab.com/group/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/project/tree/master/path')) + expect(subject).to include(link('gitlab.com/group/project/path', 'https://gitlab.com/group/project/-/tree/master/path')) + expect(subject).to include(link('gitlab.com/group/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/project/-/tree/master/path')) end it 'links Golang packages' do diff --git a/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb b/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb index 28056a6085d..ed092a846ae 100644 --- a/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb +++ b/spec/lib/gitlab/graphql/representation/submodule_tree_entry_spec.rb @@ -21,7 +21,7 @@ describe Gitlab::Graphql::Representation::SubmoduleTreeEntry do ) expect(entries.map(&:tree_url)).to contain_exactly( - "https://gitlab.com/gitlab-org/gitlab-grack/tree/645f6c4c82fd3f5e06f67134450a570b795e55a6", + "https://gitlab.com/gitlab-org/gitlab-grack/-/tree/645f6c4c82fd3f5e06f67134450a570b795e55a6", "https://github.com/gitlabhq/gitlab-shell/tree/79bceae69cb5750d6567b223597999bfa91cb3b9", "https://github.com/randx/six/tree/409f37c4f05865e4fb208c771485f211a22c4c2d" ) diff --git a/spec/lib/gitlab/middleware/go_spec.rb b/spec/lib/gitlab/middleware/go_spec.rb index 2b90035d148..99c2a364dfc 100644 --- a/spec/lib/gitlab/middleware/go_spec.rb +++ b/spec/lib/gitlab/middleware/go_spec.rb @@ -241,7 +241,7 @@ describe Gitlab::Middleware::Go do project_url = "http://#{Gitlab.config.gitlab.host}/#{path}" expect(response[0]).to eq(200) expect(response[1]['Content-Type']).to eq('text/html') - expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/tree/#{branch}{/dir} #{project_url}/blob/#{branch}{/dir}/{file}#L{line}" /></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>} + expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /><meta name="go-source" content="#{Gitlab.config.gitlab.host}/#{path} #{project_url} #{project_url}/-/tree/#{branch}{/dir} #{project_url}/-/blob/#{branch}{/dir}/{file}#L{line}" /></head><body>go get #{Gitlab.config.gitlab.url}/#{path}</body></html>} expect(response[2].body).to eq([expected_body]) end end diff --git a/spec/lib/gitlab/submodule_links_spec.rb b/spec/lib/gitlab/submodule_links_spec.rb index f0c8825de74..1f2848a29e9 100644 --- a/spec/lib/gitlab/submodule_links_spec.rb +++ b/spec/lib/gitlab/submodule_links_spec.rb @@ -38,7 +38,7 @@ describe Gitlab::SubmoduleLinks do end it 'returns links and caches the by ref' do - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) cache_store = links.instance_variable_get("@cache_store") @@ -49,7 +49,7 @@ describe Gitlab::SubmoduleLinks do let(:ref) { 'signed-commits' } it 'returns links' do - expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash']) + expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash']) end end end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 1ae90cae4b1..c9b41c9d82e 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -189,7 +189,7 @@ describe Key, :mailer do it 'removes key from authorized_file' do key = create(:personal_key) - expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, key.shell_id, key.key) + expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, key.shell_id) key.destroy end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0b39cfa1243..ee65561cc3e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -725,7 +725,7 @@ describe Project do let(:project) { create(:project, :repository) } it 'returns the README' do - expect(project.readme_url).to eq("#{project.web_url}/blob/master/README.md") + expect(project.readme_url).to eq("#{project.web_url}/-/blob/master/README.md") end end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 8b62e332407..845c906129f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1817,10 +1817,28 @@ describe Repository do end describe '#after_import' do + subject { repository.after_import } + it 'flushes and builds the cache' do expect(repository).to receive(:expire_content_cache) - repository.after_import + subject + end + + it 'calls DetectRepositoryLanguagesWorker' do + expect(DetectRepositoryLanguagesWorker).to receive(:perform_async) + + subject + end + + context 'with a wiki repository' do + let(:repository) { project.wiki.repository } + + it 'does not call DetectRepositoryLanguagesWorker' do + expect(DetectRepositoryLanguagesWorker).not_to receive(:perform_async) + + subject + end end end diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index 8680e8b9b45..ee7bfd1256d 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -21,7 +21,7 @@ describe BlobPresenter, :seed_helper do subject { described_class.new(blob) } - it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/blob/#{blob.commit_id}/#{blob.path}") } + it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/-/blob/#{blob.commit_id}/#{blob.path}") } end describe '#highlight' do diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index 6ce6f84cf61..025f083ab27 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -334,7 +334,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:target_branch_exists?) { true } is_expected - .to eq("/#{resource.target_project.full_path}/commits/#{resource.target_branch}") + .to eq("/#{resource.target_project.full_path}/-/commits/#{resource.target_branch}") end end @@ -358,7 +358,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:source_branch_exists?) { true } is_expected - .to eq("/#{resource.source_project.full_path}/commits/#{resource.source_branch}") + .to eq("/#{resource.source_project.full_path}/-/commits/#{resource.source_branch}") end end @@ -382,7 +382,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:target_branch_exists?) { true } is_expected - .to eq("/#{resource.target_project.full_path}/tree/#{resource.target_branch}") + .to eq("/#{resource.target_project.full_path}/-/tree/#{resource.target_branch}") end end @@ -496,7 +496,7 @@ describe MergeRequestPresenter do allow(resource).to receive(:source_branch_exists?) { true } is_expected - .to eq("<a href=\"/#{resource.source_project.full_path}/tree/#{resource.source_branch}\">#{resource.source_branch}</a>") + .to eq("<a href=\"/#{resource.source_project.full_path}/-/tree/#{resource.source_branch}\">#{resource.source_branch}</a>") end it 'escapes html, when source_branch does not exist' do diff --git a/spec/presenters/tree_entry_presenter_spec.rb b/spec/presenters/tree_entry_presenter_spec.rb index d74ee5dc28f..0c29fe3e5ff 100644 --- a/spec/presenters/tree_entry_presenter_spec.rb +++ b/spec/presenters/tree_entry_presenter_spec.rb @@ -11,6 +11,6 @@ describe TreeEntryPresenter do let(:presenter) { described_class.new(tree) } describe '.web_url' do - it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/tree/#{tree.commit_id}/#{tree.path}") } + it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/-/tree/#{tree.commit_id}/#{tree.path}") } end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 62cc6ee086b..6ac7b4af452 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -812,7 +812,7 @@ describe API::Projects do post api('/projects', user), params: project - expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/blob/master/README.md") + expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/-/blob/master/README.md") end it 'sets tag list to a project' do diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index c3a5c0b0caa..d9c398923c5 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -834,7 +834,7 @@ describe 'Git HTTP requests' do Blob.decorate(Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt'), project) end - get "/#{project.full_path}/blob/master/info/refs" + get "/#{project.full_path}/-/blob/master/info/refs" end it "returns the file" do @@ -844,7 +844,7 @@ describe 'Git HTTP requests' do context "when the file does not exist" do before do - get "/#{project.full_path}/blob/master/info/refs" + get "/#{project.full_path}/-/blob/master/info/refs" end it "redirects" do diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 8a1d34b2ecc..a46381fcedf 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -273,16 +273,16 @@ describe 'project routing' do end it 'to #logs_tree' do - expect(get('/gitlab/gitlabhq/refs/stable/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable') - expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45') - expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45') - expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45') - expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45', path: 'foo/bar/baz') - expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'files.scss') - assert_routing({ path: "/gitlab/gitlabhq/refs/stable/logs_tree/new%0A%0Aline.txt", + expect(get('/gitlab/gitlabhq/-/refs/stable/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable') + expect(get('/gitlab/gitlabhq/-/refs/feature%2345/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45') + expect(get('/gitlab/gitlabhq/-/refs/feature%2B45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45') + expect(get('/gitlab/gitlabhq/-/refs/feature@45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45') + expect(get('/gitlab/gitlabhq/-/refs/stable/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/feature%2345/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45', path: 'foo/bar/baz') + expect(get('/gitlab/gitlabhq/-/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'files.scss') + assert_routing({ path: "/gitlab/gitlabhq/-/refs/stable/logs_tree/new%0A%0Aline.txt", method: :get }, { controller: 'projects/refs', action: 'logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -460,9 +460,14 @@ describe 'project routing' do it_behaves_like 'RESTful project resources' do let(:actions) { [:show] } let(:controller) { 'commits' } + let(:controller_path) { '/-/commits' } end it 'to #show' do + expect(get('/gitlab/gitlabhq/-/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.atom') + end + + it 'to #show unscoped routing' do expect(get('/gitlab/gitlabhq/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.atom') end end @@ -556,11 +561,11 @@ describe 'project routing' do # project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /[^\0]+/, project_id: /[^\/]+/} describe Projects::BlameController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - expect(get('/gitlab/gitlabhq/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') + expect(get('/gitlab/gitlabhq/-/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + expect(get('/gitlab/gitlabhq/-/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/blame/master/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/blame/master/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blame', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -571,44 +576,44 @@ describe 'project routing' do # project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /[^\0]+/, project_id: /[^\/]+/} describe Projects::BlobController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - expect(get('/gitlab/gitlabhq/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb') - expect(get('/gitlab/gitlabhq/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js') - expect(get('/gitlab/gitlabhq/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') - expect(get('/gitlab/gitlabhq/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/blob/index.js') - expect(get('/gitlab/gitlabhq/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js') + expect(get('/gitlab/gitlabhq/-/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + expect(get('/gitlab/gitlabhq/-/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb') + expect(get('/gitlab/gitlabhq/-/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js') + expect(get('/gitlab/gitlabhq/-/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') + expect(get('/gitlab/gitlabhq/-/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/blob/index.js') + expect(get('/gitlab/gitlabhq/-/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/blob/blob/master/blob/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/blob/blob/master/blob/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blob', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "blob/master/blob/#{newline_file}" }) end - it 'to #show from scope routing' do - expect(get('/gitlab/gitlabhq/-/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + it 'to #show from unscoped routing' do + expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end # project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /[^\0]+/, project_id: /[^\/]+/} describe Projects::TreeController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - expect(get('/gitlab/gitlabhq/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') - expect(get('/gitlab/gitlabhq/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/tree/files') - expect(get('/gitlab/gitlabhq/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files') + expect(get('/gitlab/gitlabhq/-/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + expect(get('/gitlab/gitlabhq/-/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss') + expect(get('/gitlab/gitlabhq/-/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/tree/files') + expect(get('/gitlab/gitlabhq/-/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/tree/master/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/tree/master/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/tree', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "master/#{newline_file}" }) end - it 'to #show from scope routing' do - expect(get('/gitlab/gitlabhq/-/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + it 'to #show from unscoped routing' do + expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end @@ -616,10 +621,10 @@ describe 'project routing' do # project_files GET /:namespace_id/:project_id/files/*id(.:format) projects/find_file#list {:id=>/(?:[^.]|\.(?!json$))+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/json/} describe Projects::FindFileController, 'routing' do it 'to #show' do - expect(get('/gitlab/gitlabhq/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master') + expect(get('/gitlab/gitlabhq/-/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/find_file/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/find_file/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/find_file', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -627,10 +632,10 @@ describe 'project routing' do end it 'to #list' do - expect(get('/gitlab/gitlabhq/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json') + expect(get('/gitlab/gitlabhq/-/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json') newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/files/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/files/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/find_file', action: 'list', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -640,13 +645,13 @@ describe 'project routing' do describe Projects::BlobController, 'routing' do it 'to #edit' do - expect(get('/gitlab/gitlabhq/edit/master/app/models/project.rb')).to( + expect(get('/gitlab/gitlabhq/-/edit/master/app/models/project.rb')).to( route_to('projects/blob#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')) newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/edit/master/docs/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blob', action: 'edit', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -654,13 +659,13 @@ describe 'project routing' do end it 'to #preview' do - expect(post('/gitlab/gitlabhq/preview/master/app/models/project.rb')).to( + expect(post('/gitlab/gitlabhq/-/preview/master/app/models/project.rb')).to( route_to('projects/blob#preview', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')) newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/edit/master/docs/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/edit/master/docs/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/blob', action: 'edit', namespace_id: 'gitlab', project_id: 'gitlabhq', @@ -673,12 +678,16 @@ describe 'project routing' do it 'to #show' do newline_file = "new\n\nline.txt" url_encoded_newline_file = ERB::Util.url_encode(newline_file) - assert_routing({ path: "/gitlab/gitlabhq/raw/master/#{url_encoded_newline_file}", + assert_routing({ path: "/gitlab/gitlabhq/-/raw/master/#{url_encoded_newline_file}", method: :get }, { controller: 'projects/raw', action: 'show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "master/#{newline_file}" }) end + + it 'to #show from unscoped routing' do + expect(get('/gitlab/gitlabhq/raw/master/app/models/project.rb')).to route_to('projects/raw#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end end # project_compare_index GET /:project_id/compare(.:format) compare#index {id: /[^\/]+/, project_id: /[^\/]+/} diff --git a/spec/serializers/blob_entity_spec.rb b/spec/serializers/blob_entity_spec.rb index 7e3a0a87bd5..3cd967ed44c 100644 --- a/spec/serializers/blob_entity_spec.rb +++ b/spec/serializers/blob_entity_spec.rb @@ -23,7 +23,7 @@ describe BlobEntity do mode: "100644", readable_text: true, icon: "file-text-o", - url: "/#{project.full_path}/blob/master/bar/branch-test.txt" + url: "/#{project.full_path}/-/blob/master/bar/branch-test.txt" }) end end diff --git a/spec/serializers/merge_request_poll_widget_entity_spec.rb b/spec/serializers/merge_request_poll_widget_entity_spec.rb index ea9052b4046..0593dd527cc 100644 --- a/spec/serializers/merge_request_poll_widget_entity_spec.rb +++ b/spec/serializers/merge_request_poll_widget_entity_spec.rb @@ -60,7 +60,7 @@ describe MergeRequestPollWidgetEntity do project.add_developer(user) expect(subject[:new_blob_path]) - .to eq("/#{resource.project.full_path}/new/#{resource.source_branch}") + .to eq("/#{resource.project.full_path}/-/new/#{resource.source_branch}") end end diff --git a/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb b/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb new file mode 100644 index 00000000000..db9b89f090f --- /dev/null +++ b/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe Ci::CreatePipelineService do + context '.pre/.post stages' do + let_it_be(:user) { create(:admin) } + let_it_be(:project) { create(:project, :repository, creator: user) } + + let(:source) { :push } + let(:service) { described_class.new(project, user, { ref: ref }) } + let(:pipeline) { service.execute(source) } + + let(:config) do + <<~YAML + validate: + stage: .pre + script: echo Hello World + + build: + stage: build + rules: + - if: $CI_COMMIT_BRANCH == "master" + script: echo Hello World + + notify: + stage: .post + script: echo Hello World + YAML + end + + before do + stub_ci_pipeline_yaml_file(config) + end + + context 'when pipeline contains a build except .pre/.post' do + let(:ref) { 'refs/heads/master' } + + it 'creates a pipeline' do + expect(pipeline).to be_persisted + expect(pipeline.stages.map(&:name)).to contain_exactly( + *%w(.pre build .post)) + expect(pipeline.builds.map(&:name)).to contain_exactly( + *%w(validate build notify)) + end + end + + context 'when pipeline does not contain any other build except .pre/.post' do + let(:ref) { 'refs/heads/feature' } + + it 'does not create a pipeline' do + expect(pipeline).not_to be_persisted + + # we can validate a list of stages, as they are assigned + # but not persisted + expect(pipeline.stages.map(&:name)).to contain_exactly( + *%w(.pre .post)) + end + end + end +end diff --git a/spec/services/system_notes/merge_requests_service_spec.rb b/spec/services/system_notes/merge_requests_service_spec.rb index 2a04e888ae0..f5c071502f5 100644 --- a/spec/services/system_notes/merge_requests_service_spec.rb +++ b/spec/services/system_notes/merge_requests_service_spec.rb @@ -253,7 +253,7 @@ describe ::SystemNotes::MergeRequestsService do end it "posts the 'picked merge request' system note" do - expect(subject.note).to eq("picked this merge request into branch [`#{branch_name}`](/#{project.full_path}/tree/#{branch_name}) with commit #{commit_sha}") + expect(subject.note).to eq("picked this merge request into branch [`#{branch_name}`](/#{project.full_path}/-/tree/#{branch_name}) with commit #{commit_sha}") end it 'links the merge request and the cherry-pick commit' do diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb index 474a294ce0d..98040da9d2c 100644 --- a/spec/views/help/index.html.haml_spec.rb +++ b/spec/views/help/index.html.haml_spec.rb @@ -40,7 +40,7 @@ describe 'help/index' do render expect(rendered).to match '8.0.2' - expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/commits/abcdefg}) + expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/(gitlab|gitlab-foss)/-/commits/abcdefg}) end end end |