Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2018-04-12 21:47:30 +0300
committerClement Ho <ClemMakesApps@gmail.com>2018-04-12 21:47:30 +0300
commitb8401cd0b201ab9caecb60dcc477637e70da4df9 (patch)
treee197770a94a39ea4956007503440d13cf0b5434e
parentb75f9721df6c7f5231a9d19e38ec8f0395957c0d (diff)
parent7f01d49b69130343d95d7ec470d69aeb14fb94fe (diff)
Merge branch 'master' into bootstrap4
-rw-r--r--.gitlab-ci.yml45
-rw-r--r--CHANGELOG.md18
-rw-r--r--GITALY_SERVER_VERSION2
-rw-r--r--GITLAB_WORKHORSE_VERSION2
-rw-r--r--Gemfile.rails5.lock6
-rw-r--r--app/assets/javascripts/commit/pipelines/pipelines_table.vue26
-rw-r--r--app/assets/javascripts/ide/components/repo_editor.vue4
-rw-r--r--app/assets/javascripts/notes.js4
-rw-r--r--app/assets/javascripts/notes/components/comment_form.vue4
-rw-r--r--app/assets/javascripts/notes/components/note_actions.vue9
-rw-r--r--app/assets/javascripts/notes/components/note_awards_list.vue11
-rw-r--r--app/assets/javascripts/notes/components/note_body.vue1
-rw-r--r--app/assets/javascripts/notes/components/noteable_discussion.vue4
-rw-r--r--app/assets/javascripts/notes/components/noteable_note.vue1
-rw-r--r--app/assets/javascripts/pages/projects/edit/index.js4
-rw-r--r--app/assets/javascripts/pages/projects/new/index.js4
-rw-r--r--app/assets/javascripts/pages/projects/shared/project_new.js152
-rw-r--r--app/assets/javascripts/pages/projects/shared/save_project_loader.js12
-rw-r--r--app/assets/javascripts/pages/sessions/new/signin_tabs_memoizer.js2
-rw-r--r--app/assets/javascripts/pipelines/components/pipelines.vue64
-rw-r--r--app/assets/javascripts/pipelines/components/stage.vue18
-rw-r--r--app/assets/javascripts/pipelines/pipeline_details_mediator.js6
-rw-r--r--app/assets/javascripts/pipelines/services/pipeline_service.js13
-rw-r--r--app/assets/javascripts/pipelines/services/pipelines_service.js37
-rw-r--r--app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.js17
-rw-r--r--app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.vue20
-rw-r--r--app/assets/javascripts/sidebar/components/time_tracking/help_state.vue (renamed from app/assets/javascripts/sidebar/components/time_tracking/help_state.js)49
-rw-r--r--app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue8
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/components/states/unresolved_discussions.vue12
-rw-r--r--app/assets/javascripts/vue_shared/components/markdown/header.vue10
-rw-r--r--app/assets/stylesheets/pages/diff.scss1
-rw-r--r--app/assets/stylesheets/pages/login.scss20
-rw-r--r--app/assets/stylesheets/pages/note_form.scss13
-rw-r--r--app/assets/stylesheets/pages/notes.scss16
-rw-r--r--app/assets/stylesheets/pages/pipelines.scss8
-rw-r--r--app/assets/stylesheets/pages/projects.scss5
-rw-r--r--app/controllers/admin/application_settings_controller.rb2
-rw-r--r--app/controllers/concerns/checks_collaboration.rb21
-rw-r--r--app/controllers/concerns/notes_actions.rb4
-rw-r--r--app/controllers/concerns/renders_notes.rb2
-rw-r--r--app/controllers/groups_controller.rb4
-rw-r--r--app/controllers/projects/application_controller.rb14
-rw-r--r--app/controllers/projects/commit_controller.rb1
-rw-r--r--app/controllers/projects/issues_controller.rb2
-rw-r--r--app/controllers/projects/merge_requests/creations_controller.rb2
-rw-r--r--app/controllers/projects/notes_controller.rb2
-rw-r--r--app/finders/issuable_finder.rb11
-rw-r--r--app/finders/merge_request_target_project_finder.rb1
-rw-r--r--app/helpers/blob_helper.rb6
-rw-r--r--app/helpers/ci_status_helper.rb4
-rw-r--r--app/helpers/commits_helper.rb2
-rw-r--r--app/helpers/compare_helper.rb2
-rw-r--r--app/helpers/issues_helper.rb15
-rw-r--r--app/helpers/markup_helper.rb2
-rw-r--r--app/helpers/merge_requests_helper.rb12
-rw-r--r--app/helpers/notes_helper.rb4
-rw-r--r--app/helpers/projects_helper.rb66
-rw-r--r--app/models/ability.rb4
-rw-r--r--app/models/broadcast_message.rb6
-rw-r--r--app/models/concerns/awardable.rb14
-rw-r--r--app/models/deploy_token.rb2
-rw-r--r--app/models/event.rb3
-rw-r--r--app/policies/ci/build_policy.rb4
-rw-r--r--app/policies/ci/pipeline_schedule_policy.rb14
-rw-r--r--app/policies/issuable_policy.rb2
-rw-r--r--app/policies/note_policy.rb11
-rw-r--r--app/policies/personal_snippet_policy.rb2
-rw-r--r--app/policies/project_policy.rb96
-rw-r--r--app/policies/project_policy/class_methods.rb19
-rw-r--r--app/presenters/merge_request_presenter.rb11
-rw-r--r--app/serializers/issue_entity.rb4
-rw-r--r--app/serializers/note_entity.rb6
-rw-r--r--app/services/auth/container_registry_authentication_service.rb3
-rw-r--r--app/services/ci/register_job_service.rb19
-rw-r--r--app/services/events/render_service.rb12
-rw-r--r--app/services/merge_requests/create_service.rb4
-rw-r--r--app/services/notes/render_service.rb13
-rw-r--r--app/views/admin/projects/show.html.haml2
-rw-r--r--app/views/admin/users/_user.html.haml2
-rw-r--r--app/views/award_emoji/_awards_block.html.haml4
-rw-r--r--app/views/devise/shared/_tab_single.html.haml2
-rw-r--r--app/views/devise/shared/_tabs_ldap.html.haml2
-rw-r--r--app/views/devise/shared/_tabs_normal.html.haml2
-rw-r--r--app/views/layouts/header/_new_dropdown.haml4
-rw-r--r--app/views/layouts/nav/sidebar/_project.html.haml2
-rw-r--r--app/views/projects/_last_push.html.haml7
-rw-r--r--app/views/projects/_visibility_select.html.haml9
-rw-r--r--app/views/projects/branches/_branch.html.haml4
-rw-r--r--app/views/projects/buttons/_dropdown.html.haml22
-rw-r--r--app/views/projects/clusters/_empty_state.html.haml5
-rw-r--r--app/views/projects/commit/_commit_box.html.haml11
-rw-r--r--app/views/projects/commit/show.html.haml2
-rw-r--r--app/views/projects/commits/_commit.html.haml3
-rw-r--r--app/views/projects/edit.html.haml11
-rw-r--r--app/views/projects/issues/_nav_btns.html.haml13
-rw-r--r--app/views/projects/issues/_new_branch.html.haml8
-rw-r--r--app/views/projects/issues/show.html.haml13
-rw-r--r--app/views/projects/jobs/show.html.haml2
-rw-r--r--app/views/projects/merge_requests/index.html.haml2
-rw-r--r--app/views/projects/notes/_actions.html.haml2
-rw-r--r--app/views/projects/protected_branches/shared/_branches_list.html.haml2
-rw-r--r--app/views/projects/protected_tags/shared/_tags_list.html.haml2
-rw-r--r--app/views/projects/show.html.haml2
-rw-r--r--app/views/projects/tags/_tag.html.haml6
-rw-r--r--app/views/projects/tags/show.html.haml2
-rw-r--r--app/views/projects/tree/_tree_header.html.haml33
-rw-r--r--app/views/shared/_label.html.haml26
-rw-r--r--app/views/shared/milestones/_sidebar.html.haml4
-rw-r--r--app/views/shared/notes/_form.html.haml35
-rw-r--r--app/views/shared/notes/_note.html.haml2
-rwxr-xr-xbin/spinach5
-rw-r--r--changelogs/unreleased/40487-axios-pipelines.yml4
-rw-r--r--changelogs/unreleased/41436-use-simpler-env-vars-for-auto-devops-replicas.yml5
-rw-r--r--changelogs/unreleased/41748-vertical-misalignment-login-box.yml5
-rw-r--r--changelogs/unreleased/43794-fix-domain-verification-validation-errors.yml5
-rw-r--r--changelogs/unreleased/44541-fix-file-tree-commit-status-cache.yml5
-rw-r--r--changelogs/unreleased/44649-reference-parsing-conflicting-with-auto-linking.yml5
-rw-r--r--changelogs/unreleased/44697-prevue.yml5
-rw-r--r--changelogs/unreleased/44717-no-resolve-issue.yml5
-rw-r--r--changelogs/unreleased/44870-remove-extra-space-around-comment-form-on-merge-requests.yml5
-rw-r--r--changelogs/unreleased/45070-prometheus-integration-via-kubernetes-is-broken.yml5
-rw-r--r--changelogs/unreleased/45159-fix-illustration.yml5
-rw-r--r--changelogs/unreleased/45287-align-icons.yml5
-rw-r--r--changelogs/unreleased/ab-37125-assigned-issues-query.yml5
-rw-r--r--changelogs/unreleased/blackst0ne-replace-spinach-project-commits-branches-feature.yml5
-rw-r--r--changelogs/unreleased/blackst0ne-replace-spinach-project-issues-milestones-feature.yml5
-rw-r--r--changelogs/unreleased/deploy-tokens-container-registry-specs.yml5
-rw-r--r--changelogs/unreleased/dm-refs-contains-sha-encoding.yml5
-rw-r--r--changelogs/unreleased/fix-gb-fix-background-pipeline-stages-migration.yml5
-rw-r--r--changelogs/unreleased/fix-wiki-find-file-gitaly.yml5
-rw-r--r--changelogs/unreleased/fl-pipelines-details-axios.yml5
-rw-r--r--changelogs/unreleased/improve-jobs-queuing-time-metric.yml5
-rw-r--r--changelogs/unreleased/issue_44551.yml5
-rw-r--r--changelogs/unreleased/jivl-change-copy-text-promote-milestones-labels.yml5
-rw-r--r--changelogs/unreleased/move-estimate-only-pane-vue-component.yml5
-rw-r--r--changelogs/unreleased/move-help-state-vue-component.yml5
-rw-r--r--changelogs/unreleased/rename-overview-project-sidenav.yml5
-rw-r--r--changelogs/unreleased/rendering-markdown-multiple-projects.yml5
-rw-r--r--changelogs/unreleased/sh-cleanup-pages-worker.yml5
-rw-r--r--changelogs/unreleased/unresolved-discussions-vue-component-i18n-and-tests.yml5
-rw-r--r--changelogs/unreleased/winh-dropdown-entry-unlocking.yml5
-rw-r--r--changelogs/unreleased/zj-branch-containing-sha-opt-out.yml5
-rw-r--r--changelogs/unreleased/zj-tag-containing-sha-opt-out.yml5
-rw-r--r--config/karma.config.js19
-rw-r--r--db/fixtures/development/01_admin.rb20
-rw-r--r--db/fixtures/development/10_merge_requests.rb8
-rw-r--r--db/fixtures/development/19_environments.rb6
-rw-r--r--doc/README.md6
-rw-r--r--doc/ci/yaml/README.md79
-rw-r--r--doc/development/gitaly.md73
-rw-r--r--doc/development/i18n/externalization.md17
-rw-r--r--doc/development/new_fe_guide/development/components.md20
-rw-r--r--doc/development/testing_guide/frontend_testing.md28
-rw-r--r--doc/install/installation.md2
-rw-r--r--doc/topics/autodevops/index.md37
-rw-r--r--doc/update/10.6-to-10.7.md361
-rw-r--r--doc/user/discussions/index.md5
-rw-r--r--doc/user/project/integrations/prometheus_library/cloudwatch.md2
-rw-r--r--doc/user/project/integrations/prometheus_library/haproxy.md2
-rw-r--r--doc/user/project/integrations/prometheus_library/metrics.md3
-rw-r--r--doc/user/project/integrations/prometheus_library/nginx.md2
-rw-r--r--doc/user/project/integrations/prometheus_library/nginx_ingress.md6
-rw-r--r--doc/user/project/settings/index.md15
-rw-r--r--features/project/commits/branches.feature42
-rw-r--r--features/project/issues/milestones.feature43
-rw-r--r--features/project/project.feature86
-rw-r--r--features/steps/project/commits/branches.rb57
-rw-r--r--features/steps/project/issues/milestones.rb58
-rw-r--r--features/steps/project/project.rb154
-rw-r--r--features/steps/shared/markdown.rb4
-rw-r--r--features/steps/shared/paths.rb16
-rw-r--r--features/steps/shared/project.rb84
-rw-r--r--lib/api/merge_requests.rb2
-rw-r--r--lib/api/v3/merge_requests.rb2
-rw-r--r--lib/banzai/commit_renderer.rb2
-rw-r--r--lib/banzai/filter/issuable_state_filter.rb3
-rw-r--r--lib/banzai/filter/redactor_filter.rb6
-rw-r--r--lib/banzai/issuable_extractor.rb14
-rw-r--r--lib/banzai/object_renderer.rb32
-rw-r--r--lib/banzai/redactor.rb20
-rw-r--r--lib/banzai/reference_extractor.rb4
-rw-r--r--lib/banzai/reference_parser/base_parser.rb16
-rw-r--r--lib/banzai/reference_parser/issue_parser.rb39
-rw-r--r--lib/banzai/reference_parser/user_parser.rb3
-rw-r--r--lib/banzai/render_context.rb32
-rw-r--r--lib/gitlab/ci/status/build/common.rb8
-rw-r--r--lib/gitlab/ci/status/build/erased.rb2
-rw-r--r--lib/gitlab/ci/variables/collection/item.rb7
-rw-r--r--lib/gitlab/email/handler/create_merge_request_handler.rb3
-rw-r--r--lib/gitlab/git.rb4
-rw-r--r--lib/gitlab/git/attributes_parser.rb12
-rw-r--r--lib/gitlab/git/info_attributes.rb49
-rw-r--r--lib/gitlab/git/raw_diff_change.rb60
-rw-r--r--lib/gitlab/git/repository.rb77
-rwxr-xr-xlib/gitlab/git/support/format-git-cat-file-input21
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb10
-rw-r--r--lib/gitlab/gitaly_client/repository_service.rb9
-rw-r--r--lib/gitlab/gitaly_client/wiki_service.rb2
-rw-r--r--lib/gitlab/user_access.rb2
-rw-r--r--lib/gitlab/utils.rb4
-rw-r--r--lib/rspec_flaky/config.rb4
-rw-r--r--lib/rspec_flaky/flaky_examples_collection.rb10
-rw-r--r--lib/rspec_flaky/listener.rb39
-rw-r--r--lib/rspec_flaky/report.rb54
-rw-r--r--package.json5
-rwxr-xr-xscripts/prune-old-flaky-specs24
-rw-r--r--spec/controllers/concerns/checks_collaboration_spec.rb55
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb18
-rw-r--r--spec/factories/award_emoji.rb4
-rw-r--r--spec/factories/ci/builds.rb1
-rw-r--r--spec/features/admin/admin_broadcast_messages_spec.rb2
-rw-r--r--spec/features/dashboard/projects_spec.rb4
-rw-r--r--spec/features/groups/show_spec.rb2
-rw-r--r--spec/features/merge_request/user_awards_emoji_spec.rb8
-rw-r--r--spec/features/merge_request/user_cherry_picks_spec.rb8
-rw-r--r--spec/features/milestones/show_spec.rb26
-rw-r--r--spec/features/milestones/user_creates_milestone_spec.rb29
-rw-r--r--spec/features/milestones/user_deletes_milestone_spec.rb25
-rw-r--r--spec/features/milestones/user_views_milestone_spec.rb31
-rw-r--r--spec/features/milestones/user_views_milestones_spec.rb35
-rw-r--r--spec/features/projects/activity/rss_spec.rb7
-rw-r--r--spec/features/projects/activity/user_sees_activity_spec.rb21
-rw-r--r--spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb70
-rw-r--r--spec/features/projects/branches/user_creates_branch_spec.rb46
-rw-r--r--spec/features/projects/branches/user_deletes_branch_spec.rb23
-rw-r--r--spec/features/projects/branches/user_views_branches_spec.rb34
-rw-r--r--spec/features/projects/branches_spec.rb22
-rw-r--r--spec/features/projects/commit/cherry_pick_spec.rb11
-rw-r--r--spec/features/projects/commit/user_reverts_commit_spec.rb17
-rw-r--r--spec/features/projects/edit_spec.rb62
-rw-r--r--spec/features/projects/files/browse_files_spec.rb46
-rw-r--r--spec/features/projects/files/creating_a_file_spec.rb37
-rw-r--r--spec/features/projects/files/dockerfile_dropdown_spec.rb13
-rw-r--r--spec/features/projects/files/download_buttons_spec.rb34
-rw-r--r--spec/features/projects/files/edit_file_soft_wrap_spec.rb7
-rw-r--r--spec/features/projects/files/editing_a_file_spec.rb9
-rw-r--r--spec/features/projects/files/files_sort_submodules_with_folders_spec.rb7
-rw-r--r--spec/features/projects/files/find_file_keyboard_spec.rb5
-rw-r--r--spec/features/projects/files/gitignore_dropdown_spec.rb13
-rw-r--r--spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb13
-rw-r--r--spec/features/projects/files/project_owner_creates_license_file_spec.rb12
-rw-r--r--spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb9
-rw-r--r--spec/features/projects/files/template_type_dropdown_spec.rb31
-rw-r--r--spec/features/projects/files/undo_template_spec.rb9
-rw-r--r--spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb (renamed from spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb)4
-rw-r--r--spec/features/projects/files/user_browses_files_spec.rb (renamed from spec/features/projects/user_browses_files_spec.rb)82
-rw-r--r--spec/features/projects/files/user_browses_lfs_files_spec.rb57
-rw-r--r--spec/features/projects/files/user_creates_directory_spec.rb (renamed from spec/features/projects/user_creates_directory_spec.rb)2
-rw-r--r--spec/features/projects/files/user_creates_files_spec.rb (renamed from spec/features/projects/user_creates_files_spec.rb)27
-rw-r--r--spec/features/projects/files/user_deletes_files_spec.rb (renamed from spec/features/projects/user_deletes_files_spec.rb)2
-rw-r--r--spec/features/projects/files/user_edits_files_spec.rb (renamed from spec/features/projects/user_edits_files_spec.rb)25
-rw-r--r--spec/features/projects/files/user_reads_pipeline_status_spec.rb46
-rw-r--r--spec/features/projects/files/user_replaces_files_spec.rb (renamed from spec/features/projects/user_replaces_files_spec.rb)2
-rw-r--r--spec/features/projects/files/user_searches_for_files_spec.rb18
-rw-r--r--spec/features/projects/files/user_uploads_files_spec.rb (renamed from spec/features/projects/user_uploads_files_spec.rb)24
-rw-r--r--spec/features/projects/guest_navigation_menu_spec.rb82
-rw-r--r--spec/features/projects/issues/user_views_issue_spec.rb18
-rw-r--r--spec/features/projects/jobs_spec.rb11
-rw-r--r--spec/features/projects/merge_request_button_spec.rb12
-rw-r--r--spec/features/projects/merge_requests/user_reverts_merge_request_spec.rb8
-rw-r--r--spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb12
-rw-r--r--spec/features/projects/project_settings_spec.rb205
-rw-r--r--spec/features/projects/settings/forked_project_settings_spec.rb2
-rw-r--r--spec/features/projects/settings/integration_settings_spec.rb28
-rw-r--r--spec/features/projects/settings/lfs_settings_spec.rb21
-rw-r--r--spec/features/projects/settings/pipelines_settings_spec.rb14
-rw-r--r--spec/features/projects/settings/repository_settings_spec.rb20
-rw-r--r--spec/features/projects/settings/user_archives_project_spec.rb (renamed from spec/features/projects/user_archives_project_spec.rb)12
-rw-r--r--spec/features/projects/settings/user_changes_avatar_spec.rb44
-rw-r--r--spec/features/projects/settings/user_changes_default_branch_spec.rb20
-rw-r--r--spec/features/projects/settings/user_manages_group_links_spec.rb2
-rw-r--r--spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb (renamed from spec/features/projects/settings/merge_requests_settings_spec.rb)52
-rw-r--r--spec/features/projects/settings/user_manages_project_members_spec.rb2
-rw-r--r--spec/features/projects/settings/user_renames_a_project_spec.rb100
-rw-r--r--spec/features/projects/settings/user_tags_project_spec.rb23
-rw-r--r--spec/features/projects/settings/user_transfers_a_project_spec.rb73
-rw-r--r--spec/features/projects/settings/visibility_settings_spec.rb40
-rw-r--r--spec/features/projects/show/developer_views_empty_project_instructions_spec.rb (renamed from spec/features/projects/developer_views_empty_project_instructions_spec.rb)2
-rw-r--r--spec/features/projects/show/download_buttons_spec.rb (renamed from spec/features/projects/main/download_buttons_spec.rb)2
-rw-r--r--spec/features/projects/show/no_password_spec.rb (renamed from spec/features/projects/no_password_spec.rb)0
-rw-r--r--spec/features/projects/show/redirects_spec.rb (renamed from spec/features/projects/redirects_spec.rb)2
-rw-r--r--spec/features/projects/show/rss_spec.rb (renamed from spec/features/projects/main/rss_spec.rb)2
-rw-r--r--spec/features/projects/show/user_interacts_with_stars_spec.rb (renamed from spec/features/projects/user_interacts_with_stars_spec.rb)2
-rw-r--r--spec/features/projects/show/user_manages_notifications_spec.rb19
-rw-r--r--spec/features/projects/show/user_sees_collaboration_links_spec.rb87
-rw-r--r--spec/features/projects/show/user_sees_deletion_failure_message_spec.rb18
-rw-r--r--spec/features/projects/show/user_sees_git_instructions_spec.rb (renamed from spec/features/projects/user_views_details_spec.rb)23
-rw-r--r--spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb18
-rw-r--r--spec/features/projects/show/user_sees_readme_spec.rb16
-rw-r--r--spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb318
-rw-r--r--spec/features/projects/show_project_spec.rb359
-rw-r--r--spec/features/projects/snippets/create_snippet_spec.rb2
-rw-r--r--spec/features/projects/snippets/show_spec.rb2
-rw-r--r--spec/features/projects/snippets/user_comments_on_snippet_spec.rb14
-rw-r--r--spec/features/projects/snippets/user_deletes_snippet_spec.rb2
-rw-r--r--spec/features/projects/snippets/user_updates_snippet_spec.rb2
-rw-r--r--spec/features/projects/snippets/user_views_snippets_spec.rb14
-rw-r--r--spec/features/projects/snippets_spec.rb49
-rw-r--r--spec/features/projects/user_sees_sidebar_spec.rb106
-rw-r--r--spec/features/projects/user_transfers_a_project_spec.rb49
-rw-r--r--spec/features/projects/user_uses_shortcuts_spec.rb6
-rw-r--r--spec/features/users/login_spec.rb2
-rw-r--r--spec/finders/merge_request_target_project_finder_spec.rb6
-rw-r--r--spec/fixtures/big-image.pngbin0 -> 324444 bytes
-rw-r--r--spec/helpers/issues_helper_spec.rb45
-rw-r--r--spec/helpers/projects_helper_spec.rb68
-rw-r--r--spec/javascripts/commit/pipelines/pipelines_spec.js165
-rw-r--r--spec/javascripts/fixtures/linked_tabs.html.haml2
-rw-r--r--spec/javascripts/fixtures/signin_tabs.html.haml8
-rw-r--r--spec/javascripts/ide/components/repo_editor_spec.js39
-rw-r--r--spec/javascripts/notes/components/note_actions_spec.js4
-rw-r--r--spec/javascripts/notes/components/note_awards_list_spec.js34
-rw-r--r--spec/javascripts/notes/components/note_body_spec.js1
-rw-r--r--spec/javascripts/notes/mock_data.js15
-rw-r--r--spec/javascripts/pipelines/pipeline_details_mediator_spec.js36
-rw-r--r--spec/javascripts/pipelines/pipelines_spec.js143
-rw-r--r--spec/javascripts/pipelines/stage_spec.js85
-rw-r--r--spec/javascripts/signin_tabs_memoizer_spec.js8
-rw-r--r--spec/javascripts/test_bundle.js33
-rw-r--r--spec/javascripts/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js50
-rw-r--r--spec/javascripts/vue_shared/components/markdown/header_spec.js33
-rw-r--r--spec/lib/banzai/commit_renderer_spec.rb5
-rw-r--r--spec/lib/banzai/issuable_extractor_spec.rb2
-rw-r--r--spec/lib/banzai/object_renderer_spec.rb9
-rw-r--r--spec/lib/banzai/redactor_spec.rb4
-rw-r--r--spec/lib/banzai/reference_parser/base_parser_spec.rb18
-rw-r--r--spec/lib/banzai/reference_parser/commit_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/commit_range_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/external_issue_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/issue_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/label_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/merge_request_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/milestone_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/snippet_parser_spec.rb2
-rw-r--r--spec/lib/banzai/reference_parser/user_parser_spec.rb2
-rw-r--r--spec/lib/banzai/render_context_spec.rb37
-rw-r--r--spec/lib/gitlab/ci/status/build/common_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/status/build/factory_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/variables/collection/item_spec.rb35
-rw-r--r--spec/lib/gitlab/email/handler_spec.rb10
-rw-r--r--spec/lib/gitlab/git/attributes_parser_spec.rb12
-rw-r--r--spec/lib/gitlab/git/info_attributes_spec.rb43
-rw-r--r--spec/lib/gitlab/git/raw_diff_change_spec.rb66
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb38
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb8
-rw-r--r--spec/lib/gitlab/gitaly_client/repository_service_spec.rb11
-rw-r--r--spec/lib/gitlab/utils_spec.rb11
-rw-r--r--spec/lib/rspec_flaky/config_spec.rb30
-rw-r--r--spec/lib/rspec_flaky/flaky_examples_collection_spec.rb14
-rw-r--r--spec/lib/rspec_flaky/listener_spec.rb114
-rw-r--r--spec/lib/rspec_flaky/report_spec.rb125
-rw-r--r--spec/models/ability_spec.rb56
-rw-r--r--spec/models/broadcast_message_spec.rb6
-rw-r--r--spec/models/concerns/awardable_spec.rb25
-rw-r--r--spec/models/deploy_token_spec.rb31
-rw-r--r--spec/models/project_wiki_spec.rb12
-rw-r--r--spec/policies/note_policy_spec.rb4
-rw-r--r--spec/policies/personal_snippet_policy_spec.rb11
-rw-r--r--spec/policies/project_policy_spec.rb93
-rw-r--r--spec/requests/api/merge_requests_spec.rb4
-rw-r--r--spec/requests/api/v3/merge_requests_spec.rb4
-rw-r--r--spec/services/auth/container_registry_authentication_service_spec.rb136
-rw-r--r--spec/services/ci/register_job_service_spec.rb83
-rw-r--r--spec/services/events/render_service_spec.rb6
-rw-r--r--spec/services/merge_requests/create_service_spec.rb24
-rw-r--r--spec/services/notes/render_service_spec.rb25
-rw-r--r--spec/support/bare_repo_operations.rb10
-rw-r--r--spec/support/filter_spec_helper.rb5
-rw-r--r--spec/support/helpers/features/branches_helpers.rb33
-rw-r--r--spec/support/matchers/have_emoji.rb5
-rw-r--r--spec/support/reference_parser_helpers.rb8
-rw-r--r--spec/views/projects/buttons/_dropdown.html.haml_spec.rb3
-rw-r--r--spec/views/projects/commit/_commit_box.html.haml_spec.rb8
-rw-r--r--vendor/gitignore/Android.gitignore2
-rw-r--r--vendor/gitignore/Elixir.gitignore1
-rw-r--r--vendor/gitignore/Global/JetBrains.gitignore15
-rw-r--r--vendor/gitignore/Global/Windows.gitignore1
-rw-r--r--vendor/gitignore/Godot.gitignore8
-rw-r--r--vendor/gitignore/Joomla.gitignore1
-rw-r--r--vendor/gitignore/KiCad.gitignore5
-rw-r--r--vendor/gitignore/Leiningen.gitignore1
-rw-r--r--vendor/gitignore/Node.gitignore2
-rw-r--r--vendor/gitignore/Python.gitignore3
-rw-r--r--vendor/gitignore/Rails.gitignore1
-rw-r--r--vendor/gitignore/Rust.gitignore2
-rw-r--r--vendor/gitignore/TeX.gitignore2
-rw-r--r--vendor/gitignore/Unity.gitignore2
-rw-r--r--vendor/gitignore/VisualStudio.gitignore8
-rw-r--r--vendor/gitlab-ci-yml/Auto-DevOps.gitlab-ci.yml53
-rw-r--r--vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml2
-rw-r--r--vendor/gitlab-ci-yml/Pages/Gatsby.gitlab-ci.yml17
-rw-r--r--vendor/gitlab-ci-yml/Pages/Hugo.gitlab-ci.yml2
-rw-r--r--vendor/gitlab-ci-yml/Python.gitlab-ci.yml23
-rw-r--r--vendor/licenses.csv129
-rw-r--r--yarn.lock6
395 files changed, 4973 insertions, 3617 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4659722854e..71ddebef662 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -364,10 +364,11 @@ update-tests-metadata:
- rspec_flaky/
policy: push
script:
- - retry gem install fog-aws mime-types
+ - retry gem install fog-aws mime-types activesupport
- scripts/merge-reports ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/rspec-pg_node_*.json
- scripts/merge-reports ${KNAPSACK_SPINACH_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/spinach-pg_node_*.json
- scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
+ - FLAKY_RSPEC_GENERATE_REPORT=1 scripts/prune-old-flaky-specs ${FLAKY_RSPEC_SUITE_REPORT_PATH}
- '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $KNAPSACK_RSPEC_SUITE_REPORT_PATH $KNAPSACK_SPINACH_SUITE_REPORT_PATH'
- '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $FLAKY_RSPEC_SUITE_REPORT_PATH'
- rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
@@ -735,16 +736,50 @@ codequality:
expire_in: 1 week
sast:
- <<: *except-docs
- image: registry.gitlab.com/gitlab-org/gl-sast:latest
+ <<: *dedicated-no-docs-no-db-pull-cache-job
+ image: docker:stable
variables:
- CONFIDENCE_LEVEL: 2
+ SAST_CONFIDENCE_LEVEL: 2
+ DOCKER_DRIVER: overlay2
+ allow_failure: true
+ tags: []
before_script: []
+ cache: {}
+ dependencies: []
+ services:
+ - docker:stable-dind
script:
- - /app/bin/run .
+ - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
+ - docker run
+ --env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
+ --volume "$PWD:/code"
+ --volume /var/run/docker.sock:/var/run/docker.sock
+ "registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
artifacts:
paths: [gl-sast-report.json]
+dependency_scanning:
+ <<: *dedicated-no-docs-no-db-pull-cache-job
+ image: docker:stable
+ variables:
+ DOCKER_DRIVER: overlay2
+ allow_failure: true
+ tags: []
+ before_script: []
+ cache: {}
+ dependencies: []
+ services:
+ - docker:stable-dind
+ script:
+ - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
+ - docker run
+ --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
+ --volume "$PWD:/code"
+ --volume /var/run/docker.sock:/var/run/docker.sock
+ "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
+ artifacts:
+ paths: [gl-dependency-scanning-report.json]
+
qa:internal:
<<: *dedicated-no-docs-no-db-pull-cache-job
services: []
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9109f04fb17..d56c86523f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,24 @@
documentation](doc/development/changelog.md) for instructions on adding your own
entry.
+## 10.6.4 (2018-04-09)
+
+### Fixed (8 changes, 1 of them is from the community)
+
+- Correct copy text for the promote milestone and label modals. !17726
+- Avoid validation errors when running the Pages domain verification service. !17992
+- Fix autolinking URLs containing ampersands. !18045
+- Fix exceptions raised when migrating pipeline stages in the background. !18076
+- Work around Prometheus Helm chart name changes to fix integration. !18206 (joshlambert)
+- Don't show Jump to Discussion button on Issues.
+- Fix listing commit branch/tags that contain special characters.
+- Fix 404 in group boards when moving issue between lists.
+
+### Performance (1 change)
+
+- Free open file descriptors and libgit2 buffers in UpdatePagesService.
+
+
## 10.6.3 (2018-04-03)
### Security (2 changes)
diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION
index c5c735103b2..5f8cbfdb7d7 100644
--- a/GITALY_SERVER_VERSION
+++ b/GITALY_SERVER_VERSION
@@ -1 +1 @@
-0.94.0
+0.95.0
diff --git a/GITLAB_WORKHORSE_VERSION b/GITLAB_WORKHORSE_VERSION
index fcdb2e109f6..ee74734aa22 100644
--- a/GITLAB_WORKHORSE_VERSION
+++ b/GITLAB_WORKHORSE_VERSION
@@ -1 +1 @@
-4.0.0
+4.1.0
diff --git a/Gemfile.rails5.lock b/Gemfile.rails5.lock
index 03fe5f2ed26..c953b9708a0 100644
--- a/Gemfile.rails5.lock
+++ b/Gemfile.rails5.lock
@@ -321,6 +321,9 @@ GEM
rubyntlm (~> 0.5)
globalid (0.4.1)
activesupport (>= 4.2.0)
+ goldiloader (2.0.1)
+ activerecord (>= 4.2, < 5.2)
+ activesupport (>= 4.2, < 5.2)
gollum-grit_adapter (1.0.1)
gitlab-grit (~> 2.7, >= 2.7.1)
gollum-lib (4.2.7)
@@ -878,7 +881,7 @@ GEM
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
slack-notifier (1.5.1)
- spinach (0.10.1)
+ spinach (0.8.10)
colorize
gherkin-ruby (>= 0.3.2)
json
@@ -1072,6 +1075,7 @@ DEPENDENCIES
gitlab-markup (~> 1.6.2)
gitlab-styles (~> 2.3)
gitlab_omniauth-ldap (~> 2.0.4)
+ goldiloader (~> 2.0)
gollum-lib (~> 4.2)
gollum-rugged_adapter (~> 0.4.4)
gon (~> 6.1.0)
diff --git a/app/assets/javascripts/commit/pipelines/pipelines_table.vue b/app/assets/javascripts/commit/pipelines/pipelines_table.vue
index 466a5b5d635..24d63b99a29 100644
--- a/app/assets/javascripts/commit/pipelines/pipelines_table.vue
+++ b/app/assets/javascripts/commit/pipelines/pipelines_table.vue
@@ -55,22 +55,20 @@
},
methods: {
successCallback(resp) {
- return resp.json().then((response) => {
- // depending of the endpoint the response can either bring a `pipelines` key or not.
- const pipelines = response.pipelines || response;
- this.setCommonData(pipelines);
+ // depending of the endpoint the response can either bring a `pipelines` key or not.
+ const pipelines = resp.data.pipelines || resp.data;
+ this.setCommonData(pipelines);
- const updatePipelinesEvent = new CustomEvent('update-pipelines-count', {
- detail: {
- pipelines: response,
- },
- });
-
- // notifiy to update the count in tabs
- if (this.$el.parentElement) {
- this.$el.parentElement.dispatchEvent(updatePipelinesEvent);
- }
+ const updatePipelinesEvent = new CustomEvent('update-pipelines-count', {
+ detail: {
+ pipelines: resp.data,
+ },
});
+
+ // notifiy to update the count in tabs
+ if (this.$el.parentElement) {
+ this.$el.parentElement.dispatchEvent(updatePipelinesEvent);
+ }
},
},
};
diff --git a/app/assets/javascripts/ide/components/repo_editor.vue b/app/assets/javascripts/ide/components/repo_editor.vue
index a195162b7f2..e18972f4298 100644
--- a/app/assets/javascripts/ide/components/repo_editor.vue
+++ b/app/assets/javascripts/ide/components/repo_editor.vue
@@ -22,7 +22,7 @@ export default {
...mapState(['rightPanelCollapsed', 'viewer', 'delayViewerUpdated', 'panelResizing']),
...mapGetters(['currentMergeRequest']),
shouldHideEditor() {
- return this.file && this.file.binary && !this.file.raw;
+ return this.file && this.file.binary && !this.file.content;
},
editTabCSS() {
return {
@@ -212,7 +212,7 @@ export default {
<content-viewer
v-if="shouldHideEditor || file.viewMode === 'preview'"
:content="file.content || file.raw"
- :path="file.rawPath"
+ :path="file.rawPath || file.path"
:file-size="file.size"
:project-path="file.projectId"/>
</div>
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js
index ed72ffc532b..b4daeb7067b 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -1190,12 +1190,12 @@ export default class Notes {
addForm = false;
let lineTypeSelector = '';
rowCssToAdd =
- '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line" colspan="2"></td><td class="notes_content"><div class="content discussion-notes"></div></td></tr>';
+ '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line" colspan="2"></td><td class="notes_content"><div class="content"></div></td></tr>';
// In parallel view, look inside the correct left/right pane
if (this.isParallelView()) {
lineTypeSelector = `.${lineType}`;
rowCssToAdd =
- '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line old"></td><td class="notes_content parallel old"><div class="content discussion-notes"></div></td><td class="notes_line new"></td><td class="notes_content parallel new"><div class="content discussion-notes"></div></td></tr>';
+ '<tr class="notes_holder js-temp-notes-holder"><td class="notes_line old"></td><td class="notes_content parallel old"><div class="content"></div></td><td class="notes_line new"></td><td class="notes_content parallel new"><div class="content"></div></td></tr>';
}
const notesContentSelector = `.notes_content${lineTypeSelector} .content`;
let notesContent = targetRow.find(notesContentSelector);
diff --git a/app/assets/javascripts/notes/components/comment_form.vue b/app/assets/javascripts/notes/components/comment_form.vue
index 439d5fb895f..8d7f65d6a68 100644
--- a/app/assets/javascripts/notes/components/comment_form.vue
+++ b/app/assets/javascripts/notes/components/comment_form.vue
@@ -317,10 +317,10 @@ Please check your network connection and try again.`;
<note-signed-out-widget v-if="!isLoggedIn" />
<discussion-locked-widget
issuable-type="issue"
- v-else-if="!canCreateNote"
+ v-else-if="isLocked(getNoteableData) && !canCreateNote"
/>
<ul
- v-else
+ v-else-if="canCreateNote"
class="notes notes-form timeline">
<li class="timeline-entry">
<div class="timeline-entry-inner">
diff --git a/app/assets/javascripts/notes/components/note_actions.vue b/app/assets/javascripts/notes/components/note_actions.vue
index a7e2d857013..626b0799581 100644
--- a/app/assets/javascripts/notes/components/note_actions.vue
+++ b/app/assets/javascripts/notes/components/note_actions.vue
@@ -40,6 +40,10 @@ export default {
type: Boolean,
required: true,
},
+ canAwardEmoji: {
+ type: Boolean,
+ required: true,
+ },
canDelete: {
type: Boolean,
required: true,
@@ -74,9 +78,6 @@ export default {
shouldShowActionsDropdown() {
return this.currentUserId && (this.canEdit || this.canReportAsAbuse);
},
- canAddAwardEmoji() {
- return this.currentUserId;
- },
isAuthoredByCurrentUser() {
return this.authorId === this.currentUserId;
},
@@ -149,7 +150,7 @@ export default {
</button>
</div>
<div
- v-if="canAddAwardEmoji"
+ v-if="canAwardEmoji"
class="note-actions-item">
<a
v-tooltip
diff --git a/app/assets/javascripts/notes/components/note_awards_list.vue b/app/assets/javascripts/notes/components/note_awards_list.vue
index 6cb8229e268..e8fd155a1ee 100644
--- a/app/assets/javascripts/notes/components/note_awards_list.vue
+++ b/app/assets/javascripts/notes/components/note_awards_list.vue
@@ -28,6 +28,10 @@ export default {
type: Number,
required: true,
},
+ canAwardEmoji: {
+ type: Boolean,
+ required: true,
+ },
},
computed: {
...mapGetters(['getUserData']),
@@ -67,9 +71,6 @@ export default {
isAuthoredByMe() {
return this.noteAuthorId === this.getUserData.id;
},
- isLoggedIn() {
- return this.getUserData.id;
- },
},
created() {
this.emojiSmiling = emojiSmiling;
@@ -156,7 +157,7 @@ export default {
return title;
},
handleAward(awardName) {
- if (!this.isLoggedIn) {
+ if (!this.canAwardEmoji) {
return;
}
@@ -208,7 +209,7 @@ export default {
</span>
</button>
<div
- v-if="isLoggedIn"
+ v-if="canAwardEmoji"
class="award-menu-holder">
<button
v-tooltip
diff --git a/app/assets/javascripts/notes/components/note_body.vue b/app/assets/javascripts/notes/components/note_body.vue
index 069f94c5845..0cb626c14f4 100644
--- a/app/assets/javascripts/notes/components/note_body.vue
+++ b/app/assets/javascripts/notes/components/note_body.vue
@@ -112,6 +112,7 @@ export default {
:note-author-id="note.author.id"
:awards="note.award_emoji"
:toggle-award-path="note.toggle_award_path"
+ :can-award-emoji="note.current_user.can_award_emoji"
/>
<note-attachment
v-if="note.attachment"
diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue
index 64283fa5f37..7b9ff2b14f1 100644
--- a/app/assets/javascripts/notes/components/noteable_discussion.vue
+++ b/app/assets/javascripts/notes/components/noteable_discussion.vue
@@ -258,7 +258,9 @@ Please check your network connection and try again.`;
:key="note.id"
/>
</ul>
- <div class="discussion-reply-holder">
+ <div
+ :class="{ 'is-replying': isReplying }"
+ class="discussion-reply-holder">
<template v-if="!isReplying && canReply">
<div
class="btn-group d-flex discussion-with-resolve-btn"
diff --git a/app/assets/javascripts/notes/components/noteable_note.vue b/app/assets/javascripts/notes/components/noteable_note.vue
index 3554027d2b4..566f5c68e66 100644
--- a/app/assets/javascripts/notes/components/noteable_note.vue
+++ b/app/assets/javascripts/notes/components/noteable_note.vue
@@ -177,6 +177,7 @@ export default {
:note-id="note.id"
:access-level="note.human_access"
:can-edit="note.current_user.can_edit"
+ :can-award-emoji="note.current_user.can_award_emoji"
:can-delete="note.current_user.can_edit"
:can-report-as-abuse="canReportAsAbuse"
:report-abuse-path="note.report_abuse_path"
diff --git a/app/assets/javascripts/pages/projects/edit/index.js b/app/assets/javascripts/pages/projects/edit/index.js
index be37df36be8..628913483c6 100644
--- a/app/assets/javascripts/pages/projects/edit/index.js
+++ b/app/assets/javascripts/pages/projects/edit/index.js
@@ -1,12 +1,12 @@
import initSettingsPanels from '~/settings_panels';
import setupProjectEdit from '~/project_edit';
import initConfirmDangerModal from '~/confirm_danger_modal';
-import ProjectNew from '../shared/project_new';
+import initProjectLoadingSpinner from '../shared/save_project_loader';
import projectAvatar from '../shared/project_avatar';
import initProjectPermissionsSettings from '../shared/permissions';
document.addEventListener('DOMContentLoaded', () => {
- new ProjectNew(); // eslint-disable-line no-new
+ initProjectLoadingSpinner();
setupProjectEdit();
// Initialize expandable settings panels
initSettingsPanels();
diff --git a/app/assets/javascripts/pages/projects/new/index.js b/app/assets/javascripts/pages/projects/new/index.js
index ea6fd961393..7db644e2477 100644
--- a/app/assets/javascripts/pages/projects/new/index.js
+++ b/app/assets/javascripts/pages/projects/new/index.js
@@ -1,9 +1,9 @@
-import ProjectNew from '../shared/project_new';
+import initProjectLoadingSpinner from '../shared/save_project_loader';
import initProjectVisibilitySelector from '../../../project_visibility';
import initProjectNew from '../../../projects/project_new';
document.addEventListener('DOMContentLoaded', () => {
- new ProjectNew(); // eslint-disable-line no-new
+ initProjectLoadingSpinner();
initProjectVisibilitySelector();
initProjectNew.bindEvents();
});
diff --git a/app/assets/javascripts/pages/projects/shared/project_new.js b/app/assets/javascripts/pages/projects/shared/project_new.js
deleted file mode 100644
index 56d5574aa2f..00000000000
--- a/app/assets/javascripts/pages/projects/shared/project_new.js
+++ /dev/null
@@ -1,152 +0,0 @@
-/* eslint-disable func-names, no-var, no-underscore-dangle, prefer-template, prefer-arrow-callback*/
-
-import $ from 'jquery';
-import VisibilitySelect from '../../../visibility_select';
-
-function highlightChanges($elm) {
- $elm.addClass('highlight-changes');
- setTimeout(() => $elm.removeClass('highlight-changes'), 10);
-}
-
-export default class ProjectNew {
- constructor() {
- this.toggleSettings = this.toggleSettings.bind(this);
- this.$selects = $('.features select');
- this.$repoSelects = this.$selects.filter('.js-repo-select');
- this.$projectSelects = this.$selects.not('.js-repo-select');
-
- $('.project-edit-container').on('ajax:before', () => {
- $('.project-edit-container').hide();
- return $('.save-project-loader').show();
- });
-
- this.initVisibilitySelect();
-
- this.toggleSettings();
- this.toggleSettingsOnclick();
- this.toggleRepoVisibility();
- }
-
- initVisibilitySelect() {
- const visibilityContainer = document.querySelector('.js-visibility-select');
- if (!visibilityContainer) return;
- const visibilitySelect = new VisibilitySelect(visibilityContainer);
- visibilitySelect.init();
-
- const $visibilitySelect = $(visibilityContainer).find('select');
- let projectVisibility = $visibilitySelect.val();
- const PROJECT_VISIBILITY_PRIVATE = '0';
-
- $visibilitySelect.on('change', () => {
- const newProjectVisibility = $visibilitySelect.val();
-
- if (projectVisibility !== newProjectVisibility) {
- this.$projectSelects.each((idx, select) => {
- const $select = $(select);
- const $options = $select.find('option');
- const values = $.map($options, e => e.value);
-
- // if switched to "private", limit visibility options
- if (newProjectVisibility === PROJECT_VISIBILITY_PRIVATE) {
- if ($select.val() !== values[0] && $select.val() !== values[1]) {
- $select.val(values[1]).trigger('change');
- highlightChanges($select);
- }
- $options.slice(2).disable();
- }
-
- // if switched from "private", increase visibility for non-disabled options
- if (projectVisibility === PROJECT_VISIBILITY_PRIVATE) {
- $options.enable();
- if ($select.val() !== values[0] && $select.val() !== values[values.length - 1]) {
- $select.val(values[values.length - 1]).trigger('change');
- highlightChanges($select);
- }
- }
- });
-
- projectVisibility = newProjectVisibility;
- }
- });
- }
-
- toggleSettings() {
- this.$selects.each(function () {
- var $select = $(this);
- var className = $select.data('field')
- .replace(/_/g, '-')
- .replace('access-level', 'feature');
- ProjectNew._showOrHide($select, '.' + className);
- });
- }
-
- toggleSettingsOnclick() {
- this.$selects.on('change', this.toggleSettings);
- }
-
- static _showOrHide(checkElement, container) {
- const $container = $(container);
-
- if ($(checkElement).val() !== '0') {
- return $container.show();
- }
- return $container.hide();
- }
-
- toggleRepoVisibility() {
- var $repoAccessLevel = $('.js-repo-access-level select');
- var $lfsEnabledOption = $('.js-lfs-enabled select');
- var containerRegistry = document.querySelectorAll('.js-container-registry')[0];
- var containerRegistryCheckbox = document.getElementById('project_container_registry_enabled');
- var prevSelectedVal = parseInt($repoAccessLevel.val(), 10);
-
- this.$repoSelects.find("option[value='" + $repoAccessLevel.val() + "']")
- .nextAll()
- .hide();
-
- $repoAccessLevel
- .off('change')
- .on('change', function () {
- var selectedVal = parseInt($repoAccessLevel.val(), 10);
-
- this.$repoSelects.each(function () {
- var $this = $(this);
- var repoSelectVal = parseInt($this.val(), 10);
-
- $this.find('option').enable();
-
- if (selectedVal < repoSelectVal || repoSelectVal === prevSelectedVal) {
- $this.val(selectedVal).trigger('change');
- highlightChanges($this);
- }
-
- $this.find("option[value='" + selectedVal + "']").nextAll().disable();
- });
-
- if (selectedVal) {
- this.$repoSelects.removeClass('disabled');
-
- if ($lfsEnabledOption.length) {
- $lfsEnabledOption.removeClass('disabled');
- highlightChanges($lfsEnabledOption);
- }
- if (containerRegistry) {
- containerRegistry.style.display = '';
- }
- } else {
- this.$repoSelects.addClass('disabled');
-
- if ($lfsEnabledOption.length) {
- $lfsEnabledOption.val('false').addClass('disabled');
- highlightChanges($lfsEnabledOption);
- }
- if (containerRegistry) {
- containerRegistry.style.display = 'none';
- containerRegistryCheckbox.checked = false;
- }
- }
-
- prevSelectedVal = selectedVal;
- }.bind(this));
- }
-}
diff --git a/app/assets/javascripts/pages/projects/shared/save_project_loader.js b/app/assets/javascripts/pages/projects/shared/save_project_loader.js
new file mode 100644
index 00000000000..aa3589ac88d
--- /dev/null
+++ b/app/assets/javascripts/pages/projects/shared/save_project_loader.js
@@ -0,0 +1,12 @@
+import $ from 'jquery';
+
+export default function initProjectLoadingSpinner() {
+ const $formContainer = $('.project-edit-container');
+ const $loadingSpinner = $('.save-project-loader');
+
+ // show loading spinner when saving
+ $formContainer.on('ajax:before', () => {
+ $formContainer.hide();
+ $loadingSpinner.show();
+ });
+}
diff --git a/app/assets/javascripts/pages/sessions/new/signin_tabs_memoizer.js b/app/assets/javascripts/pages/sessions/new/signin_tabs_memoizer.js
index 08f0afdcce3..d321892d2d2 100644
--- a/app/assets/javascripts/pages/sessions/new/signin_tabs_memoizer.js
+++ b/app/assets/javascripts/pages/sessions/new/signin_tabs_memoizer.js
@@ -5,7 +5,7 @@ import AccessorUtilities from '~/lib/utils/accessor';
* Does that setting the current selected tab in the localStorage
*/
export default class SigninTabsMemoizer {
- constructor({ currentTabKey = 'current_signin_tab', tabSelector = 'ul.nav-tabs' } = {}) {
+ constructor({ currentTabKey = 'current_signin_tab', tabSelector = 'ul.new-session-tabs' } = {}) {
this.currentTabKey = currentTabKey;
this.tabSelector = tabSelector;
this.isLocalStorageAvailable = AccessorUtilities.isLocalStorageAccessSafe();
diff --git a/app/assets/javascripts/pipelines/components/pipelines.vue b/app/assets/javascripts/pipelines/components/pipelines.vue
index e0a7284124d..497a09cec65 100644
--- a/app/assets/javascripts/pipelines/components/pipelines.vue
+++ b/app/assets/javascripts/pipelines/components/pipelines.vue
@@ -7,10 +7,7 @@
import TablePagination from '../../vue_shared/components/table_pagination.vue';
import NavigationTabs from '../../vue_shared/components/navigation_tabs.vue';
import NavigationControls from './nav_controls.vue';
- import {
- getParameterByName,
- parseQueryStringIntoObject,
- } from '../../lib/utils/common_utils';
+ import { getParameterByName } from '../../lib/utils/common_utils';
import CIPaginationMixin from '../../vue_shared/mixins/ci_pagination_api_mixin';
export default {
@@ -19,10 +16,7 @@
NavigationTabs,
NavigationControls,
},
- mixins: [
- pipelinesMixin,
- CIPaginationMixin,
- ],
+ mixins: [pipelinesMixin, CIPaginationMixin],
props: {
store: {
type: Object,
@@ -147,25 +141,26 @@
*/
shouldRenderTabs() {
const { stateMap } = this.$options;
- return this.hasMadeRequest &&
- [
- stateMap.loading,
- stateMap.tableList,
- stateMap.error,
- stateMap.emptyTab,
- ].includes(this.stateToRender);
+ return (
+ this.hasMadeRequest &&
+ [stateMap.loading, stateMap.tableList, stateMap.error, stateMap.emptyTab].includes(
+ this.stateToRender,
+ )
+ );
},
shouldRenderButtons() {
- return (this.newPipelinePath ||
- this.resetCachePath ||
- this.ciLintPath) && this.shouldRenderTabs;
+ return (
+ (this.newPipelinePath || this.resetCachePath || this.ciLintPath) && this.shouldRenderTabs
+ );
},
shouldRenderPagination() {
- return !this.isLoading &&
+ return (
+ !this.isLoading &&
this.state.pipelines.length &&
- this.state.pageInfo.total > this.state.pageInfo.perPage;
+ this.state.pageInfo.total > this.state.pageInfo.perPage
+ );
},
emptyTabMessage() {
@@ -229,15 +224,13 @@
},
methods: {
successCallback(resp) {
- return resp.json().then((response) => {
- // Because we are polling & the user is interacting verify if the response received
- // matches the last request made
- if (_.isEqual(parseQueryStringIntoObject(resp.url.split('?')[1]), this.requestData)) {
- this.store.storeCount(response.count);
- this.store.storePagination(resp.headers);
- this.setCommonData(response.pipelines);
- }
- });
+ // Because we are polling & the user is interacting verify if the response received
+ // matches the last request made
+ if (_.isEqual(resp.config.params, this.requestData)) {
+ this.store.storeCount(resp.data.count);
+ this.store.storePagination(resp.headers);
+ this.setCommonData(resp.data.pipelines);
+ }
},
/**
* Handles URL and query parameter changes.
@@ -251,8 +244,9 @@
this.updateInternalState(parameters);
// fetch new data
- return this.service.getPipelines(this.requestData)
- .then((response) => {
+ return this.service
+ .getPipelines(this.requestData)
+ .then(response => {
this.isLoading = false;
this.successCallback(response);
@@ -271,13 +265,11 @@
handleResetRunnersCache(endpoint) {
this.isResetCacheButtonLoading = true;
- this.service.postAction(endpoint)
+ this.service
+ .postAction(endpoint)
.then(() => {
this.isResetCacheButtonLoading = false;
- createFlash(
- s__('Pipelines|Project cache successfully reset.'),
- 'notice',
- );
+ createFlash(s__('Pipelines|Project cache successfully reset.'), 'notice');
})
.catch(() => {
this.isResetCacheButtonLoading = false;
diff --git a/app/assets/javascripts/pipelines/components/stage.vue b/app/assets/javascripts/pipelines/components/stage.vue
index 8bc7a1f20b2..b3fcaf0ccd1 100644
--- a/app/assets/javascripts/pipelines/components/stage.vue
+++ b/app/assets/javascripts/pipelines/components/stage.vue
@@ -13,16 +13,16 @@
* 3. Merge request widget
* 4. Commit widget
*/
-
+ import axios from '../../lib/utils/axios_utils';
import Flash from '../../flash';
- import icon from '../../vue_shared/components/icon.vue';
- import loadingIcon from '../../vue_shared/components/loading_icon.vue';
+ import Icon from '../../vue_shared/components/icon.vue';
+ import LoadingIcon from '../../vue_shared/components/loading_icon.vue';
import tooltip from '../../vue_shared/directives/tooltip';
export default {
components: {
- loadingIcon,
- icon,
+ LoadingIcon,
+ Icon,
},
directives: {
@@ -88,9 +88,8 @@
},
fetchJobs() {
- this.$http.get(this.stage.dropdown_path)
- .then(response => response.json())
- .then((data) => {
+ axios.get(this.stage.dropdown_path)
+ .then(({ data }) => {
this.dropdownContent = data.html;
this.isLoading = false;
})
@@ -98,8 +97,7 @@
this.closeDropdown();
this.isLoading = false;
- const flash = new Flash('Something went wrong on our end.');
- return flash;
+ Flash('Something went wrong on our end.');
});
},
diff --git a/app/assets/javascripts/pipelines/pipeline_details_mediator.js b/app/assets/javascripts/pipelines/pipeline_details_mediator.js
index 621969cd622..5633e54b28a 100644
--- a/app/assets/javascripts/pipelines/pipeline_details_mediator.js
+++ b/app/assets/javascripts/pipelines/pipeline_details_mediator.js
@@ -40,10 +40,8 @@ export default class pipelinesMediator {
}
successCallback(response) {
- return response.json().then((data) => {
- this.state.isLoading = false;
- this.store.storePipeline(data);
- });
+ this.state.isLoading = false;
+ this.store.storePipeline(response.data);
}
errorCallback() {
diff --git a/app/assets/javascripts/pipelines/services/pipeline_service.js b/app/assets/javascripts/pipelines/services/pipeline_service.js
index 3e0c52c7726..a53a9cc8365 100644
--- a/app/assets/javascripts/pipelines/services/pipeline_service.js
+++ b/app/assets/javascripts/pipelines/services/pipeline_service.js
@@ -1,19 +1,16 @@
-import Vue from 'vue';
-import VueResource from 'vue-resource';
-
-Vue.use(VueResource);
+import axios from '../../lib/utils/axios_utils';
export default class PipelineService {
constructor(endpoint) {
- this.pipeline = Vue.resource(endpoint);
+ this.pipeline = endpoint;
}
getPipeline() {
- return this.pipeline.get();
+ return axios.get(this.pipeline);
}
- // eslint-disable-next-line
+ // eslint-disable-next-line class-methods-use-this
postAction(endpoint) {
- return Vue.http.post(`${endpoint}.json`);
+ return axios.post(`${endpoint}.json`);
}
}
diff --git a/app/assets/javascripts/pipelines/services/pipelines_service.js b/app/assets/javascripts/pipelines/services/pipelines_service.js
index 47736fc5f42..001286f5d52 100644
--- a/app/assets/javascripts/pipelines/services/pipelines_service.js
+++ b/app/assets/javascripts/pipelines/services/pipelines_service.js
@@ -1,35 +1,27 @@
-/* eslint-disable class-methods-use-this */
-import Vue from 'vue';
-import VueResource from 'vue-resource';
-import '../../vue_shared/vue_resource_interceptor';
-
-Vue.use(VueResource);
+import axios from '../../lib/utils/axios_utils';
export default class PipelinesService {
-
/**
- * Commits and merge request endpoints need to be requested with `.json`.
- *
- * The url provided to request the pipelines in the new merge request
- * page already has `.json`.
- *
- * @param {String} root
- */
+ * Commits and merge request endpoints need to be requested with `.json`.
+ *
+ * The url provided to request the pipelines in the new merge request
+ * page already has `.json`.
+ *
+ * @param {String} root
+ */
constructor(root) {
- let endpoint;
-
if (root.indexOf('.json') === -1) {
- endpoint = `${root}.json`;
+ this.endpoint = `${root}.json`;
} else {
- endpoint = root;
+ this.endpoint = root;
}
-
- this.pipelines = Vue.resource(endpoint);
}
getPipelines(data = {}) {
const { scope, page } = data;
- return this.pipelines.get({ scope, page });
+ return axios.get(this.endpoint, {
+ params: { scope, page },
+ });
}
/**
@@ -38,7 +30,8 @@ export default class PipelinesService {
* @param {String} endpoint
* @return {Promise}
*/
+ // eslint-disable-next-line class-methods-use-this
postAction(endpoint) {
- return Vue.http.post(`${endpoint}.json`);
+ return axios.post(`${endpoint}.json`);
}
}
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.js b/app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.js
deleted file mode 100644
index 2d324c71379..00000000000
--- a/app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.js
+++ /dev/null
@@ -1,17 +0,0 @@
-export default {
- name: 'time-tracking-estimate-only-pane',
- props: {
- timeEstimateHumanReadable: {
- type: String,
- required: true,
- },
- },
- template: `
- <div class="time-tracking-estimate-only-pane">
- <span class="bold">
- {{ s__('TimeTracking|Estimated:') }}
- </span>
- {{ timeEstimateHumanReadable }}
- </div>
- `,
-};
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.vue b/app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.vue
new file mode 100644
index 00000000000..08fce597e50
--- /dev/null
+++ b/app/assets/javascripts/sidebar/components/time_tracking/estimate_only_pane.vue
@@ -0,0 +1,20 @@
+<script>
+export default {
+ name: 'TimeTrackingEstimateOnlyPane',
+ props: {
+ timeEstimateHumanReadable: {
+ type: String,
+ required: true,
+ },
+ },
+};
+</script>
+
+<template>
+ <div class="time-tracking-estimate-only-pane">
+ <span class="bold">
+ {{ s__('TimeTracking|Estimated:') }}
+ </span>
+ {{ timeEstimateHumanReadable }}
+ </div>
+</template>
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/help_state.js b/app/assets/javascripts/sidebar/components/time_tracking/help_state.vue
index 19f74ad3c6d..825063d9ba6 100644
--- a/app/assets/javascripts/sidebar/components/time_tracking/help_state.js
+++ b/app/assets/javascripts/sidebar/components/time_tracking/help_state.vue
@@ -1,7 +1,8 @@
+<script>
import { sprintf, s__ } from '../../../locale';
export default {
- name: 'time-tracking-help-state',
+ name: 'TimeTrackingHelpState',
props: {
rootPath: {
type: String,
@@ -27,26 +28,28 @@ export default {
);
},
},
- template: `
- <div class="time-tracking-help-state">
- <div class="time-tracking-info">
- <h4>
- {{ __('Track time with quick actions') }}
- </h4>
- <p>
- {{ __('Quick actions can be used in the issues description and comment boxes.') }}
- </p>
- <p v-html="estimateText">
- </p>
- <p v-html="spendText">
- </p>
- <a
- class="btn btn-default learn-more-button"
- :href="href"
- >
- {{ __('Learn more') }}
- </a>
- </div>
- </div>
- `,
};
+</script>
+
+<template>
+ <div class="time-tracking-help-state">
+ <div class="time-tracking-info">
+ <h4>
+ {{ __('Track time with quick actions') }}
+ </h4>
+ <p>
+ {{ __('Quick actions can be used in the issues description and comment boxes.') }}
+ </p>
+ <p v-html="estimateText">
+ </p>
+ <p v-html="spendText">
+ </p>
+ <a
+ class="btn btn-default learn-more-button"
+ :href="href"
+ >
+ {{ __('Learn more') }}
+ </a>
+ </div>
+ </div>
+</template>
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue b/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue
index 37fa5560d28..1ef0764bf2b 100644
--- a/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue
+++ b/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue
@@ -1,9 +1,9 @@
<script>
-import timeTrackingHelpState from './help_state';
+import TimeTrackingHelpState from './help_state.vue';
import TimeTrackingCollapsedState from './collapsed_state.vue';
import timeTrackingSpentOnlyPane from './spent_only_pane';
import timeTrackingNoTrackingPane from './no_tracking_pane';
-import timeTrackingEstimateOnlyPane from './estimate_only_pane';
+import TimeTrackingEstimateOnlyPane from './estimate_only_pane.vue';
import TimeTrackingComparisonPane from './comparison_pane.vue';
import eventHub from '../../event_hub';
@@ -12,11 +12,11 @@ export default {
name: 'IssuableTimeTracker',
components: {
TimeTrackingCollapsedState,
- 'time-tracking-estimate-only-pane': timeTrackingEstimateOnlyPane,
+ TimeTrackingEstimateOnlyPane,
'time-tracking-spent-only-pane': timeTrackingSpentOnlyPane,
'time-tracking-no-tracking-pane': timeTrackingNoTrackingPane,
TimeTrackingComparisonPane,
- 'time-tracking-help-state': timeTrackingHelpState,
+ TimeTrackingHelpState,
},
props: {
time_estimate: {
diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/unresolved_discussions.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/unresolved_discussions.vue
index eeead11650f..be9b2e463d4 100644
--- a/app/assets/javascripts/vue_merge_request_widget/components/states/unresolved_discussions.vue
+++ b/app/assets/javascripts/vue_merge_request_widget/components/states/unresolved_discussions.vue
@@ -7,7 +7,10 @@ export default {
statusIcon,
},
props: {
- mr: { type: Object, required: true },
+ mr: {
+ type: Object,
+ required: true,
+ },
},
};
</script>
@@ -20,13 +23,14 @@ export default {
/>
<div class="media-body space-children">
<span class="bold">
- There are unresolved discussions. Please resolve these discussions
+ {{ s__("mrWidget|There are unresolved discussions. Please resolve these discussions") }}
</span>
<a
v-if="mr.createIssueToResolveDiscussionsPath"
:href="mr.createIssueToResolveDiscussionsPath"
- class="btn btn-secondary btn-xs js-create-issue">
- Create an issue to resolve them later
+ class="btn btn-secondary btn-xs js-create-issue"
+ >
+ {{ s__("mrWidget|Create an issue to resolve them later") }}
</a>
</div>
</div>
diff --git a/app/assets/javascripts/vue_shared/components/markdown/header.vue b/app/assets/javascripts/vue_shared/components/markdown/header.vue
index d91fe3cf0c5..db453c30576 100644
--- a/app/assets/javascripts/vue_shared/components/markdown/header.vue
+++ b/app/assets/javascripts/vue_shared/components/markdown/header.vue
@@ -27,20 +27,22 @@
$(document).off('markdown-preview:hide.vue', this.writeMarkdownTab);
},
methods: {
- isMarkdownForm(form) {
- return form && !form.find('.js-vue-markdown-field').length;
+ isValid(form) {
+ return !form ||
+ form.find('.js-vue-markdown-field').length ||
+ $(this.$el).closest('form') === form[0];
},
previewMarkdownTab(event, form) {
if (event.target.blur) event.target.blur();
- if (this.isMarkdownForm(form)) return;
+ if (!this.isValid(form)) return;
this.$emit('preview-markdown');
},
writeMarkdownTab(event, form) {
if (event.target.blur) event.target.blur();
- if (this.isMarkdownForm(form)) return;
+ if (!this.isValid(form)) return;
this.$emit('write-markdown');
},
diff --git a/app/assets/stylesheets/pages/diff.scss b/app/assets/stylesheets/pages/diff.scss
index bdb915e6acd..2382c5e6251 100644
--- a/app/assets/stylesheets/pages/diff.scss
+++ b/app/assets/stylesheets/pages/diff.scss
@@ -813,7 +813,6 @@
}
.discussion-notes {
- padding: 0 $gl-padding $gl-padding;
min-height: 35px;
&:first-child {
diff --git a/app/assets/stylesheets/pages/login.scss b/app/assets/stylesheets/pages/login.scss
index a7196a9f8df..c1b1d2e028d 100644
--- a/app/assets/stylesheets/pages/login.scss
+++ b/app/assets/stylesheets/pages/login.scss
@@ -154,26 +154,10 @@
a {
width: 100%;
font-size: 18px;
- margin-right: 0;
-
- &:hover {
- border: 1px solid transparent;
- }
}
- &.active {
- border-bottom: 1px solid $border-color;
-
- a {
- border: 0;
- border-bottom: 2px solid $link-underline-blue;
- margin-right: 0;
- color: $black;
-
- &:hover {
- border-bottom: 2px solid $link-underline-blue;
- }
- }
+ &.active > a {
+ cursor: default;
}
}
}
diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss
index 82570c0653e..e08912e72ab 100644
--- a/app/assets/stylesheets/pages/note_form.scss
+++ b/app/assets/stylesheets/pages/note_form.scss
@@ -173,7 +173,11 @@
}
.discussion-form {
- padding-top: $gl-padding-top;
+ background-color: $white-light;
+}
+
+.discussion-form-container {
+ padding: $gl-padding-top $gl-padding $gl-padding;
}
.discussion-notes .disabled-comment {
@@ -233,7 +237,12 @@
.discussion-body,
.diff-file {
.discussion-reply-holder {
- padding-top: $gl-padding;
+ background-color: $white-light;
+ padding: 10px 16px;
+
+ &.is-replying {
+ padding-bottom: $gl-padding;
+ }
}
}
diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss
index 9a25ca275c4..998c37cd455 100644
--- a/app/assets/stylesheets/pages/notes.scss
+++ b/app/assets/stylesheets/pages/notes.scss
@@ -47,7 +47,7 @@ ul.notes {
}
.timeline-entry-inner {
- padding: $gl-padding 0;
+ padding: $gl-padding $gl-btn-padding;
border-bottom: 1px solid $white-normal;
}
@@ -94,6 +94,12 @@ ul.notes {
}
}
+ &.note-discussion {
+ .timeline-entry-inner {
+ padding: $gl-padding 10px;
+ }
+ }
+
.editing-spinner {
display: none;
}
@@ -346,8 +352,6 @@ ul.notes {
}
.discussion-notes {
- background-color: $white-light;
-
&:not(:first-child) {
border-top: 1px solid $white-normal;
margin-top: 20px;
@@ -359,6 +363,10 @@ ul.notes {
}
}
+ .notes {
+ background-color: $white-light;
+ }
+
a code {
top: 0;
margin-right: 0;
@@ -639,6 +647,8 @@ ul.notes {
border-bottom: 1px solid $white-normal;
.timeline-entry-inner {
+ padding-left: $gl-padding;
+ padding-right: $gl-padding;
border-bottom: 0;
}
}
diff --git a/app/assets/stylesheets/pages/pipelines.scss b/app/assets/stylesheets/pages/pipelines.scss
index d38b066bfe4..bea1ec4d006 100644
--- a/app/assets/stylesheets/pages/pipelines.scss
+++ b/app/assets/stylesheets/pages/pipelines.scss
@@ -344,7 +344,6 @@
svg {
vertical-align: middle;
- margin-right: 3px;
}
.stage-column {
@@ -495,17 +494,12 @@
svg {
fill: $gl-text-color-secondary;
position: relative;
- left: 1px;
top: -1px;
- width: 16px;
- height: 16px;
}
&.play {
svg {
- width: 16px;
- height: 16px;
- left: 3px;
+ left: 2px;
}
}
}
diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss
index 9395140cf4a..9edb30835b3 100644
--- a/app/assets/stylesheets/pages/projects.scss
+++ b/app/assets/stylesheets/pages/projects.scss
@@ -935,11 +935,6 @@ pre.light-well {
}
}
- .dropdown-menu-toggle {
- width: 100%;
- max-width: 300px;
- }
-
.flash-container {
padding: 0;
}
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 4dfb397e82c..145f74d9e59 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -56,7 +56,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
def application_setting_params
+ params[:application_setting] ||= {}
import_sources = params[:application_setting][:import_sources]
+
if import_sources.nil?
params[:application_setting][:import_sources] = []
else
diff --git a/app/controllers/concerns/checks_collaboration.rb b/app/controllers/concerns/checks_collaboration.rb
new file mode 100644
index 00000000000..81367663a06
--- /dev/null
+++ b/app/controllers/concerns/checks_collaboration.rb
@@ -0,0 +1,21 @@
+module ChecksCollaboration
+ def can_collaborate_with_project?(project, ref: nil)
+ return true if can?(current_user, :push_code, project)
+
+ can_create_merge_request =
+ can?(current_user, :create_merge_request_in, project) &&
+ current_user.already_forked?(project)
+
+ can_create_merge_request ||
+ user_access(project).can_push_to_branch?(ref)
+ end
+
+ # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # enabling this so we can easily cache the user access value as it might be
+ # used across multiple calls in the view
+ def user_access(project)
+ @user_access ||= {}
+ @user_access[project] ||= Gitlab::UserAccess.new(current_user, project: project)
+ end
+ # rubocop:enable Gitlab/ModuleWithInstanceVariables
+end
diff --git a/app/controllers/concerns/notes_actions.rb b/app/controllers/concerns/notes_actions.rb
index 839cac3687c..ad4e936a3d4 100644
--- a/app/controllers/concerns/notes_actions.rb
+++ b/app/controllers/concerns/notes_actions.rb
@@ -41,7 +41,7 @@ module NotesActions
@note = Notes::CreateService.new(note_project, current_user, create_params).execute
if @note.is_a?(Note)
- Notes::RenderService.new(current_user).execute([@note], @project)
+ Notes::RenderService.new(current_user).execute([@note])
end
respond_to do |format|
@@ -56,7 +56,7 @@ module NotesActions
@note = Notes::UpdateService.new(project, current_user, note_params).execute(note)
if @note.is_a?(Note)
- Notes::RenderService.new(current_user).execute([@note], @project)
+ Notes::RenderService.new(current_user).execute([@note])
end
respond_to do |format|
diff --git a/app/controllers/concerns/renders_notes.rb b/app/controllers/concerns/renders_notes.rb
index e7ef297879f..36e3d76ecfe 100644
--- a/app/controllers/concerns/renders_notes.rb
+++ b/app/controllers/concerns/renders_notes.rb
@@ -4,7 +4,7 @@ module RendersNotes
preload_noteable_for_regular_notes(notes)
preload_max_access_for_authors(notes, @project)
preload_first_time_contribution_for_authors(noteable, notes)
- Notes::RenderService.new(current_user).execute(notes, @project)
+ Notes::RenderService.new(current_user).execute(notes)
notes
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 283c3e5f1e0..5ac4b8710e2 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -173,7 +173,9 @@ class GroupsController < Groups::ApplicationController
.new(@projects, offset: params[:offset].to_i, filter: event_filter)
.to_a
- Events::RenderService.new(current_user).execute(@events, atom_request: request.format.atom?)
+ Events::RenderService
+ .new(current_user)
+ .execute(@events, atom_request: request.format.atom?)
end
def user_actions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index 6d9b42a2c04..032bb2267e7 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -1,5 +1,6 @@
class Projects::ApplicationController < ApplicationController
include RoutableActions
+ include ChecksCollaboration
skip_before_action :authenticate_user!
before_action :project
@@ -31,14 +32,6 @@ class Projects::ApplicationController < ApplicationController
@repository ||= project.repository
end
- def can_collaborate_with_project?(project = nil, ref: nil)
- project ||= @project
-
- can?(current_user, :push_code, project) ||
- (current_user && current_user.already_forked?(project)) ||
- user_access(project).can_push_to_branch?(ref)
- end
-
def authorize_action!(action)
unless can?(current_user, action, project)
return access_denied!
@@ -91,9 +84,4 @@ class Projects::ApplicationController < ApplicationController
def check_issues_available!
return render_404 unless @project.feature_available?(:issues, current_user)
end
-
- def user_access(project)
- @user_access ||= {}
- @user_access[project] ||= Gitlab::UserAccess.new(current_user, project: project)
- end
end
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index effb484ef0f..b7f548e0e63 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -34,6 +34,7 @@ class Projects::CommitController < Projects::ApplicationController
def pipelines
@pipelines = @commit.pipelines.order(id: :desc)
+ @pipelines = @pipelines.where(ref: params[:ref]) if params[:ref]
respond_to do |format|
format.html
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index b14939c4216..767e492f566 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -20,7 +20,7 @@ class Projects::IssuesController < Projects::ApplicationController
before_action :authorize_update_issuable!, only: [:edit, :update, :move]
# Allow create a new branch and empty WIP merge request from current issue
- before_action :authorize_create_merge_request!, only: [:create_merge_request]
+ before_action :authorize_create_merge_request_from!, only: [:create_merge_request]
respond_to :html
diff --git a/app/controllers/projects/merge_requests/creations_controller.rb b/app/controllers/projects/merge_requests/creations_controller.rb
index a90030a8312..4a377fefc62 100644
--- a/app/controllers/projects/merge_requests/creations_controller.rb
+++ b/app/controllers/projects/merge_requests/creations_controller.rb
@@ -5,7 +5,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
skip_before_action :merge_request
before_action :whitelist_query_limiting, only: [:create]
- before_action :authorize_create_merge_request!
+ before_action :authorize_create_merge_request_from!
before_action :apply_diff_view_cookie!, only: [:diffs, :diff_for_path]
before_action :build_merge_request, except: [:create]
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb
index dd41b9648e8..86c50d88a2a 100644
--- a/app/controllers/projects/notes_controller.rb
+++ b/app/controllers/projects/notes_controller.rb
@@ -68,7 +68,7 @@ class Projects::NotesController < Projects::ApplicationController
private
def render_json_with_notes_serializer
- Notes::RenderService.new(current_user).execute([note], project)
+ Notes::RenderService.new(current_user).execute([note])
render json: note_serializer.represent(note)
end
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index 61c72aa22a8..7ed9b1fc6d0 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -159,7 +159,10 @@ class IssuableFinder
finder_options = { include_subgroups: params[:include_subgroups], only_owned: true }
GroupProjectsFinder.new(group: group, current_user: current_user, options: finder_options).execute
else
- ProjectsFinder.new(current_user: current_user, project_ids_relation: item_project_ids(items)).execute
+ opts = { current_user: current_user }
+ opts[:project_ids_relation] = item_project_ids(items) if items
+
+ ProjectsFinder.new(opts).execute
end
@projects = projects.with_feature_available_for_user(klass, current_user).reorder(nil)
@@ -316,9 +319,9 @@ class IssuableFinder
def by_project(items)
items =
if project?
- items.of_projects(projects(items)).references_project
- elsif projects(items)
- items.merge(projects(items).reorder(nil)).join_project
+ items.of_projects(projects).references_project
+ elsif projects
+ items.merge(projects.reorder(nil)).join_project
else
items.none
end
diff --git a/app/finders/merge_request_target_project_finder.rb b/app/finders/merge_request_target_project_finder.rb
index f358938344e..188ec447a94 100644
--- a/app/finders/merge_request_target_project_finder.rb
+++ b/app/finders/merge_request_target_project_finder.rb
@@ -12,6 +12,7 @@ class MergeRequestTargetProjectFinder
if @source_project.fork_network
@source_project.fork_network.projects
.public_or_visible_to_user(current_user)
+ .non_archived
.with_feature_available_for_user(:merge_requests, current_user)
else
Project.where(id: source_project)
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 2b440e4d584..866b8773db6 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -59,7 +59,7 @@ module BlobHelper
button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' }
elsif can_modify_blob?(blob, project, ref)
button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal'
- elsif can?(current_user, :fork_project, project)
+ elsif can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project)
edit_fork_button_tag(common_classes, project, label, edit_modify_file_fork_params(action), action)
end
end
@@ -280,7 +280,7 @@ module BlobHelper
options << link_to("submit an issue", new_project_issue_path(project))
end
- merge_project = can?(current_user, :create_merge_request, project) ? project : (current_user && current_user.fork_of(project))
+ merge_project = merge_request_source_project_for_project(@project)
if merge_project
options << link_to("create a merge request", project_new_merge_request_path(project))
end
@@ -334,7 +334,7 @@ module BlobHelper
# Web IDE (Beta) requires the user to have this feature enabled
elsif !current_user || (current_user && can_modify_blob?(blob, project, ref))
edit_link_tag(text, edit_path, common_classes)
- elsif current_user && can?(current_user, :fork_project, project)
+ elsif can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project)
edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path))
end
end
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index 636316da80a..f0afcac5986 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -94,7 +94,7 @@ module CiStatusHelper
def render_project_pipeline_status(pipeline_status, tooltip_placement: 'auto left')
project = pipeline_status.project
- path = pipelines_project_commit_path(project, pipeline_status.sha)
+ path = pipelines_project_commit_path(project, pipeline_status.sha, ref: pipeline_status.ref)
render_status_with_link(
'commit',
@@ -105,7 +105,7 @@ module CiStatusHelper
def render_commit_status(commit, ref: nil, tooltip_placement: 'auto left')
project = commit.project
- path = pipelines_project_commit_path(project, commit)
+ path = pipelines_project_commit_path(project, commit, ref: ref)
render_status_with_link(
'commit',
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index c02bfea1f4d..4898867236e 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -163,7 +163,7 @@ module CommitsHelper
tooltip = "#{action.capitalize} this #{commit.change_type_title(current_user)} in a new merge request" if has_tooltip
btn_class = "btn btn-#{btn_class}" unless btn_class.nil?
- if can_collaborate_with_project?
+ if can_collaborate_with_project?(@project)
link_to action.capitalize, "#modal-#{action}-commit", 'data-toggle' => 'modal', 'data-container' => 'body', title: (tooltip if has_tooltip), class: "#{btn_class} #{'has-tooltip' if has_tooltip}"
elsif can?(current_user, :fork_project, @project)
continue_params = {
diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb
index 8bf96c0905f..2df5b5d1695 100644
--- a/app/helpers/compare_helper.rb
+++ b/app/helpers/compare_helper.rb
@@ -3,7 +3,7 @@ module CompareHelper
from.present? &&
to.present? &&
from != to &&
- can?(current_user, :create_merge_request, project) &&
+ can?(current_user, :create_merge_request_from, project) &&
project.repository.branch_exists?(from) &&
project.repository.branch_exists?(to)
end
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 0f25d401406..96dc7ae1185 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -82,8 +82,8 @@ module IssuesHelper
names.to_sentence
end
- def award_state_class(awards, current_user)
- if !current_user
+ def award_state_class(awardable, awards, current_user)
+ if !can?(current_user, :award_emoji, awardable)
"disabled"
elsif current_user && awards.find { |a| a.user_id == current_user.id }
"active"
@@ -126,6 +126,17 @@ module IssuesHelper
link_to link_text, path
end
+ def show_new_issue_link?(project)
+ return false unless project
+ return false if project.archived?
+
+ # We want to show the link to users that are not signed in, that way they
+ # get directed to the sign-in/sign-up flow and afterwards to the new issue page.
+ return true unless current_user
+
+ can?(current_user, :create_issue, project)
+ end
+
# Required for Banzai::Filter::IssueReferenceFilter
module_function :url_for_issue
module_function :url_for_internal_issue
diff --git a/app/helpers/markup_helper.rb b/app/helpers/markup_helper.rb
index 2fe1927a189..39e7a7fd396 100644
--- a/app/helpers/markup_helper.rb
+++ b/app/helpers/markup_helper.rb
@@ -256,7 +256,7 @@ module MarkupHelper
return '' unless html.present?
context.merge!(
- current_user: (current_user if defined?(current_user)),
+ current_user: (current_user if defined?(current_user)),
# RelativeLinkFilter
commit: @commit,
diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb
index fb4fe1c40b7..c19c5b9cc82 100644
--- a/app/helpers/merge_requests_helper.rb
+++ b/app/helpers/merge_requests_helper.rb
@@ -138,6 +138,18 @@ module MergeRequestsHelper
end
end
+ def merge_request_source_project_for_project(project = @project)
+ unless can?(current_user, :create_merge_request_in, project)
+ return nil
+ end
+
+ if can?(current_user, :create_merge_request_from, project)
+ project
+ else
+ current_user.fork_of(project)
+ end
+ end
+
def merge_params_ee(merge_request)
{}
end
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb
index 27ed48fdbc7..7f67574a428 100644
--- a/app/helpers/notes_helper.rb
+++ b/app/helpers/notes_helper.rb
@@ -6,10 +6,6 @@ module NotesHelper
end
end
- def note_editable?(note)
- Ability.can_edit_note?(current_user, note)
- end
-
def note_supports_quick_actions?(note)
Notes::QuickActionsService.supported?(note)
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 15f48e43a28..a64b2acdd77 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -157,40 +157,6 @@ module ProjectsHelper
current_user&.recent_push(@project)
end
- def project_feature_access_select(field)
- # Don't show option "everyone with access" if project is private
- options = project_feature_options
-
- level = @project.project_feature.public_send(field) # rubocop:disable GitlabSecurity/PublicSend
-
- if @project.private?
- disabled_option = ProjectFeature::ENABLED
- highest_available_option = ProjectFeature::PRIVATE if level == disabled_option
- end
-
- options = options_for_select(
- options.invert,
- selected: highest_available_option || level,
- disabled: disabled_option
- )
-
- content_tag :div, class: "select-wrapper" do
- concat(
- content_tag(
- :select,
- options,
- name: "project[project_feature_attributes][#{field}]",
- id: "project_project_feature_attributes_#{field}",
- class: "pull-right form-control select-control #{repo_children_classes(field)} ",
- data: { field: field }
- )
- )
- concat(
- icon('chevron-down')
- )
- end.html_safe
- end
-
def link_to_autodeploy_doc
link_to _('About auto deploy'), help_page_path('ci/autodeploy/index'), target: '_blank'
end
@@ -274,16 +240,6 @@ module ProjectsHelper
private
- def repo_children_classes(field)
- needs_repo_check = [:merge_requests_access_level, :builds_access_level]
- return unless needs_repo_check.include?(field)
-
- classes = "project-repo-select js-repo-select"
- classes << " disabled" unless @project.feature_available?(:repository, current_user)
-
- classes
- end
-
def get_project_nav_tabs(project, current_user)
nav_tabs = [:home]
@@ -447,14 +403,6 @@ module ProjectsHelper
filtered_message.gsub(project.repository_storage_path.chomp('/'), "[REPOS PATH]")
end
- def project_feature_options
- {
- ProjectFeature::DISABLED => s_('ProjectFeature|Disabled'),
- ProjectFeature::PRIVATE => s_('ProjectFeature|Only team members'),
- ProjectFeature::ENABLED => s_('ProjectFeature|Everyone with access')
- }
- end
-
def project_child_container_class(view_path)
view_path == "projects/issues/issues" ? "prepend-top-default" : "project-show-#{view_path}"
end
@@ -463,20 +411,6 @@ module ProjectsHelper
IssuesFinder.new(current_user, project_id: project.id).execute
end
- def visibility_select_options(project, selected_level)
- level_options = Gitlab::VisibilityLevel.values.each_with_object([]) do |level, level_options|
- next if restricted_levels.include?(level)
-
- level_options << [
- visibility_level_label(level),
- { data: { description: visibility_level_description(level, project) } },
- level
- ]
- end
-
- options_for_select(level_options, selected_level)
- end
-
def restricted_levels
return [] if current_user.admin?
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 6dae49f38dc..618d4af4272 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -46,10 +46,6 @@ class Ability
end
end
- def can_edit_note?(user, note)
- allowed?(user, :edit_note, note)
- end
-
def allowed?(user, action, subject = :global, opts = {})
if subject.is_a?(Hash)
opts, subject = subject, :global
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb
index 0b561203914..4aa236555cb 100644
--- a/app/models/broadcast_message.rb
+++ b/app/models/broadcast_message.rb
@@ -19,7 +19,7 @@ class BroadcastMessage < ActiveRecord::Base
after_commit :flush_redis_cache
def self.current
- messages = Rails.cache.fetch(CACHE_KEY) { current_and_future_messages.to_a }
+ messages = Rails.cache.fetch(CACHE_KEY, expires_in: cache_expires_in) { current_and_future_messages.to_a }
return messages if messages.empty?
@@ -36,6 +36,10 @@ class BroadcastMessage < ActiveRecord::Base
where('ends_at > :now', now: Time.zone.now).order_id_asc
end
+ def self.cache_expires_in
+ nil
+ end
+
def active?
started? && !ended?
end
diff --git a/app/models/concerns/awardable.rb b/app/models/concerns/awardable.rb
index d8394415362..fce37e7f78e 100644
--- a/app/models/concerns/awardable.rb
+++ b/app/models/concerns/awardable.rb
@@ -79,11 +79,7 @@ module Awardable
end
def user_can_award?(current_user, name)
- if user_authored?(current_user)
- !awardable_votes?(normalize_name(name))
- else
- true
- end
+ awardable_by_user?(current_user, name) && Ability.allowed?(current_user, :award_emoji, self)
end
def user_authored?(current_user)
@@ -119,4 +115,12 @@ module Awardable
def normalize_name(name)
Gitlab::Emoji.normalize_emoji_name(name)
end
+
+ def awardable_by_user?(current_user, name)
+ if user_authored?(current_user)
+ !awardable_votes?(normalize_name(name))
+ else
+ true
+ end
+ end
end
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index b47b2ff4c3f..8dae821a10e 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -34,7 +34,7 @@ class DeployToken < ActiveRecord::Base
end
def has_access_to?(requested_project)
- project == requested_project
+ active? && project == requested_project
end
# This is temporal. Currently we limit DeployToken
diff --git a/app/models/event.rb b/app/models/event.rb
index 3805f6cf857..741a84194e2 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -110,7 +110,10 @@ class Event < ActiveRecord::Base
end
end
+ # Remove this method when removing Gitlab.rails5? code.
def subclass_from_attributes(attrs)
+ return super if Gitlab.rails5?
+
# Without this Rails will keep calling this method on the returned class,
# resulting in an infinite loop.
return unless self == Event
diff --git a/app/policies/ci/build_policy.rb b/app/policies/ci/build_policy.rb
index 1ab391a5a9d..808a81cbbf9 100644
--- a/app/policies/ci/build_policy.rb
+++ b/app/policies/ci/build_policy.rb
@@ -11,7 +11,7 @@ module Ci
end
condition(:owner_of_job) do
- can?(:developer_access) && @subject.triggered_by?(@user)
+ @subject.triggered_by?(@user)
end
rule { protected_ref }.policy do
@@ -19,6 +19,6 @@ module Ci
prevent :erase_build
end
- rule { can?(:master_access) | owner_of_job }.enable :erase_build
+ rule { can?(:admin_build) | (can?(:update_build) & owner_of_job) }.enable :erase_build
end
end
diff --git a/app/policies/ci/pipeline_schedule_policy.rb b/app/policies/ci/pipeline_schedule_policy.rb
index dc7a4aed577..ecba0488d3c 100644
--- a/app/policies/ci/pipeline_schedule_policy.rb
+++ b/app/policies/ci/pipeline_schedule_policy.rb
@@ -7,23 +7,17 @@ module Ci
end
condition(:owner_of_schedule) do
- can?(:developer_access) && pipeline_schedule.owned_by?(@user)
+ pipeline_schedule.owned_by?(@user)
end
- condition(:non_owner_of_schedule) do
- !pipeline_schedule.owned_by?(@user)
- end
-
- rule { can?(:developer_access) }.policy do
- enable :play_pipeline_schedule
- end
+ rule { can?(:create_pipeline) }.enable :play_pipeline_schedule
- rule { can?(:master_access) | owner_of_schedule }.policy do
+ rule { can?(:admin_pipeline) | (can?(:update_build) & owner_of_schedule) }.policy do
enable :update_pipeline_schedule
enable :admin_pipeline_schedule
end
- rule { can?(:master_access) & non_owner_of_schedule }.policy do
+ rule { can?(:admin_pipeline_schedule) & ~owner_of_schedule }.policy do
enable :take_ownership_pipeline_schedule
end
diff --git a/app/policies/issuable_policy.rb b/app/policies/issuable_policy.rb
index e86d1c8f98e..b431d376e3d 100644
--- a/app/policies/issuable_policy.rb
+++ b/app/policies/issuable_policy.rb
@@ -18,9 +18,7 @@ class IssuablePolicy < BasePolicy
rule { locked & ~is_project_member }.policy do
prevent :create_note
- prevent :update_note
prevent :admin_note
prevent :resolve_note
- prevent :edit_note
end
end
diff --git a/app/policies/note_policy.rb b/app/policies/note_policy.rb
index d4cb5a77e63..077a6761ee6 100644
--- a/app/policies/note_policy.rb
+++ b/app/policies/note_policy.rb
@@ -1,26 +1,21 @@
class NotePolicy < BasePolicy
delegate { @subject.project }
- delegate { @subject.noteable if @subject.noteable.lockable? }
+ delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) }
condition(:is_author) { @user && @subject.author == @user }
- condition(:for_merge_request, scope: :subject) { @subject.for_merge_request? }
condition(:is_noteable_author) { @user && @subject.noteable.author_id == @user.id }
condition(:editable, scope: :subject) { @subject.editable? }
- rule { ~editable | anonymous }.prevent :edit_note
-
- rule { is_author | admin }.enable :edit_note
- rule { can?(:master_access) }.enable :edit_note
+ rule { ~editable }.prevent :admin_note
rule { is_author }.policy do
enable :read_note
- enable :update_note
enable :admin_note
enable :resolve_note
end
- rule { for_merge_request & is_noteable_author }.policy do
+ rule { is_noteable_author }.policy do
enable :resolve_note
end
end
diff --git a/app/policies/personal_snippet_policy.rb b/app/policies/personal_snippet_policy.rb
index cac0530b9f7..c1a84727cfa 100644
--- a/app/policies/personal_snippet_policy.rb
+++ b/app/policies/personal_snippet_policy.rb
@@ -25,4 +25,6 @@ class PersonalSnippetPolicy < BasePolicy
end
rule { anonymous }.prevent :comment_personal_snippet
+
+ rule { can?(:comment_personal_snippet) }.enable :award_emoji
end
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb
index 21bb0934dee..3529d0aa60c 100644
--- a/app/policies/project_policy.rb
+++ b/app/policies/project_policy.rb
@@ -1,12 +1,26 @@
class ProjectPolicy < BasePolicy
- def self.create_read_update_admin(name)
- [
- :"create_#{name}",
- :"read_#{name}",
- :"update_#{name}",
- :"admin_#{name}"
- ]
- end
+ extend ClassMethods
+
+ READONLY_FEATURES_WHEN_ARCHIVED = %i[
+ issue
+ list
+ merge_request
+ label
+ milestone
+ project_snippet
+ wiki
+ note
+ pipeline
+ pipeline_schedule
+ build
+ trigger
+ environment
+ deployment
+ commit_status
+ container_image
+ pages
+ cluster
+ ].freeze
desc "User is a project owner"
condition :owner do
@@ -15,7 +29,7 @@ class ProjectPolicy < BasePolicy
end
desc "Project has public builds enabled"
- condition(:public_builds, scope: :subject) { project.public_builds? }
+ condition(:public_builds, scope: :subject, score: 0) { project.public_builds? }
# For guest access we use #team_member? so we can use
# project.members, which gets cached in subject scope.
@@ -35,7 +49,7 @@ class ProjectPolicy < BasePolicy
condition(:master) { team_access_level >= Gitlab::Access::MASTER }
desc "Project is public"
- condition(:public_project, scope: :subject) { project.public? }
+ condition(:public_project, scope: :subject, score: 0) { project.public? }
desc "Project is visible to internal users"
condition(:internal_access) do
@@ -46,7 +60,7 @@ class ProjectPolicy < BasePolicy
condition(:group_member, scope: :subject) { project_group_member? }
desc "Project is archived"
- condition(:archived, scope: :subject) { project.archived? }
+ condition(:archived, scope: :subject, score: 0) { project.archived? }
condition(:default_issues_tracker, scope: :subject) { project.default_issues_tracker? }
@@ -56,10 +70,10 @@ class ProjectPolicy < BasePolicy
end
desc "Project has an external wiki"
- condition(:has_external_wiki, scope: :subject) { project.has_external_wiki? }
+ condition(:has_external_wiki, scope: :subject, score: 0) { project.has_external_wiki? }
desc "Project has request access enabled"
- condition(:request_access_enabled, scope: :subject) { project.request_access_enabled }
+ condition(:request_access_enabled, scope: :subject, score: 0) { project.request_access_enabled }
desc "Has merge requests allowing pushes to user"
condition(:has_merge_requests_allowing_pushes, scope: :subject) do
@@ -126,6 +140,7 @@ class ProjectPolicy < BasePolicy
rule { can?(:guest_access) }.policy do
enable :read_project
+ enable :create_merge_request_in
enable :read_board
enable :read_list
enable :read_wiki
@@ -140,6 +155,7 @@ class ProjectPolicy < BasePolicy
enable :create_note
enable :upload_file
enable :read_cycle_analytics
+ enable :award_emoji
end
# These abilities are not allowed to admins that are not members of the project,
@@ -197,7 +213,7 @@ class ProjectPolicy < BasePolicy
enable :create_pipeline
enable :update_pipeline
enable :create_pipeline_schedule
- enable :create_merge_request
+ enable :create_merge_request_from
enable :create_wiki
enable :push_code
enable :resolve_note
@@ -208,7 +224,7 @@ class ProjectPolicy < BasePolicy
end
rule { can?(:master_access) }.policy do
- enable :delete_protected_branch
+ enable :push_to_delete_protected_branch
enable :update_project_snippet
enable :update_environment
enable :update_deployment
@@ -231,37 +247,50 @@ class ProjectPolicy < BasePolicy
end
rule { archived }.policy do
- prevent :create_merge_request
prevent :push_code
- prevent :delete_protected_branch
- prevent :update_merge_request
- prevent :admin_merge_request
+ prevent :push_to_delete_protected_branch
+ prevent :request_access
+ prevent :upload_file
+ prevent :resolve_note
+ prevent :create_merge_request_from
+ prevent :create_merge_request_in
+ prevent :award_emoji
+
+ READONLY_FEATURES_WHEN_ARCHIVED.each do |feature|
+ prevent(*create_update_admin_destroy(feature))
+ end
+ end
+
+ rule { issues_disabled }.policy do
+ prevent(*create_read_update_admin_destroy(:issue))
end
rule { merge_requests_disabled | repository_disabled }.policy do
- prevent(*create_read_update_admin(:merge_request))
+ prevent :create_merge_request_in
+ prevent :create_merge_request_from
+ prevent(*create_read_update_admin_destroy(:merge_request))
end
rule { issues_disabled & merge_requests_disabled }.policy do
- prevent(*create_read_update_admin(:label))
- prevent(*create_read_update_admin(:milestone))
+ prevent(*create_read_update_admin_destroy(:label))
+ prevent(*create_read_update_admin_destroy(:milestone))
end
rule { snippets_disabled }.policy do
- prevent(*create_read_update_admin(:project_snippet))
+ prevent(*create_read_update_admin_destroy(:project_snippet))
end
rule { wiki_disabled & ~has_external_wiki }.policy do
- prevent(*create_read_update_admin(:wiki))
+ prevent(*create_read_update_admin_destroy(:wiki))
prevent(:download_wiki_code)
end
rule { builds_disabled | repository_disabled }.policy do
- prevent(*create_read_update_admin(:build))
- prevent(*(create_read_update_admin(:pipeline) - [:read_pipeline]))
- prevent(*create_read_update_admin(:pipeline_schedule))
- prevent(*create_read_update_admin(:environment))
- prevent(*create_read_update_admin(:deployment))
+ prevent(*create_update_admin_destroy(:pipeline))
+ prevent(*create_read_update_admin_destroy(:build))
+ prevent(*create_read_update_admin_destroy(:pipeline_schedule))
+ prevent(*create_read_update_admin_destroy(:environment))
+ prevent(*create_read_update_admin_destroy(:deployment))
end
rule { repository_disabled }.policy do
@@ -272,7 +301,7 @@ class ProjectPolicy < BasePolicy
end
rule { container_registry_disabled }.policy do
- prevent(*create_read_update_admin(:container_image))
+ prevent(*create_read_update_admin_destroy(:container_image))
end
rule { anonymous & ~public_project }.prevent_all
@@ -314,13 +343,6 @@ class ProjectPolicy < BasePolicy
enable :read_pipeline_schedule
end
- rule { issues_disabled }.policy do
- prevent :create_issue
- prevent :update_issue
- prevent :admin_issue
- prevent :read_issue
- end
-
# These rules are included to allow maintainers of projects to push to certain
# to run pipelines for the branches they have access to.
rule { can?(:public_access) & has_merge_requests_allowing_pushes }.policy do
diff --git a/app/policies/project_policy/class_methods.rb b/app/policies/project_policy/class_methods.rb
new file mode 100644
index 00000000000..60e5aba00ba
--- /dev/null
+++ b/app/policies/project_policy/class_methods.rb
@@ -0,0 +1,19 @@
+class ProjectPolicy
+ module ClassMethods
+ def create_read_update_admin_destroy(name)
+ [
+ :"read_#{name}",
+ *create_update_admin_destroy(name)
+ ]
+ end
+
+ def create_update_admin_destroy(name)
+ [
+ :"create_#{name}",
+ :"update_#{name}",
+ :"admin_#{name}",
+ :"destroy_#{name}"
+ ]
+ end
+ end
+end
diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb
index 9f3f2637183..4b4132af2d0 100644
--- a/app/presenters/merge_request_presenter.rb
+++ b/app/presenters/merge_request_presenter.rb
@@ -3,6 +3,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
include GitlabRoutingHelper
include MarkupHelper
include TreeHelper
+ include ChecksCollaboration
include Gitlab::Utils::StrongMemoize
presents :merge_request
@@ -152,11 +153,11 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
end
def can_revert_on_current_merge_request?
- user_can_collaborate_with_project? && cached_can_be_reverted?
+ can_collaborate_with_project?(project) && cached_can_be_reverted?
end
def can_cherry_pick_on_current_merge_request?
- user_can_collaborate_with_project? && can_be_cherry_picked?
+ can_collaborate_with_project?(project) && can_be_cherry_picked?
end
def can_push_to_source_branch?
@@ -195,12 +196,6 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
end.sort.to_sentence
end
- def user_can_collaborate_with_project?
- can?(current_user, :push_code, project) ||
- (current_user && current_user.already_forked?(project)) ||
- can_push_to_source_branch?
- end
-
def user_can_fork_project?
can?(current_user, :fork_project, project)
end
diff --git a/app/serializers/issue_entity.rb b/app/serializers/issue_entity.rb
index b5e2334b6e3..840fdbcbf14 100644
--- a/app/serializers/issue_entity.rb
+++ b/app/serializers/issue_entity.rb
@@ -29,6 +29,10 @@ class IssueEntity < IssuableEntity
expose :can_update do |issue|
can?(request.current_user, :update_issue, issue)
end
+
+ expose :can_award_emoji do |issue|
+ can?(request.current_user, :award_emoji, issue)
+ end
end
expose :create_note_path do |issue|
diff --git a/app/serializers/note_entity.rb b/app/serializers/note_entity.rb
index c964aa9c99b..06d603b277e 100644
--- a/app/serializers/note_entity.rb
+++ b/app/serializers/note_entity.rb
@@ -15,7 +15,11 @@ class NoteEntity < API::Entities::Note
expose :current_user do
expose :can_edit do |note|
- Ability.can_edit_note?(request.current_user, note)
+ Ability.allowed?(request.current_user, :admin_note, note)
+ end
+
+ expose :can_award_emoji do |note|
+ Ability.allowed?(request.current_user, :award_emoji, note)
end
end
diff --git a/app/services/auth/container_registry_authentication_service.rb b/app/services/auth/container_registry_authentication_service.rb
index 8f050072f74..f28cddb2af3 100644
--- a/app/services/auth/container_registry_authentication_service.rb
+++ b/app/services/auth/container_registry_authentication_service.rb
@@ -149,7 +149,8 @@ module Auth
def deploy_token_can_pull?(requested_project)
has_authentication_ability?(:read_container_image) &&
current_user.is_a?(DeployToken) &&
- current_user.has_access_to?(requested_project)
+ current_user.has_access_to?(requested_project) &&
+ current_user.read_registry?
end
##
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb
index d46dcff34a1..e09b445636f 100644
--- a/app/services/ci/register_job_service.rb
+++ b/app/services/ci/register_job_service.rb
@@ -4,9 +4,6 @@ module Ci
class RegisterJobService
attr_reader :runner
- JOB_QUEUE_DURATION_SECONDS_BUCKETS = [1, 3, 10, 30].freeze
- JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET = 5.freeze
-
Result = Struct.new(:build, :valid?)
def initialize(runner)
@@ -107,22 +104,10 @@ module Ci
end
def register_success(job)
- labels = { shared_runner: runner.shared?,
- jobs_running_for_project: jobs_running_for_project(job) }
-
- job_queue_duration_seconds.observe(labels, Time.now - job.queued_at)
+ job_queue_duration_seconds.observe({ shared_runner: @runner.shared? }, Time.now - job.created_at)
attempt_counter.increment
end
- def jobs_running_for_project(job)
- return '+Inf' unless runner.shared?
-
- # excluding currently started job
- running_jobs_count = job.project.builds.running.where(runner: Ci::Runner.shared)
- .limit(JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET + 1).count - 1
- running_jobs_count < JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET ? running_jobs_count : "#{JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET}+"
- end
-
def failed_attempt_counter
@failed_attempt_counter ||= Gitlab::Metrics.counter(:job_register_attempts_failed_total, "Counts the times a runner tries to register a job")
end
@@ -132,7 +117,7 @@ module Ci
end
def job_queue_duration_seconds
- @job_queue_duration_seconds ||= Gitlab::Metrics.histogram(:job_queue_duration_seconds, 'Request handling execution time', {}, JOB_QUEUE_DURATION_SECONDS_BUCKETS)
+ @job_queue_duration_seconds ||= Gitlab::Metrics.histogram(:job_queue_duration_seconds, 'Request handling execution time')
end
end
end
diff --git a/app/services/events/render_service.rb b/app/services/events/render_service.rb
index 0b62d8aedf1..bb72d7685dd 100644
--- a/app/services/events/render_service.rb
+++ b/app/services/events/render_service.rb
@@ -1,15 +1,17 @@
module Events
class RenderService < BaseRenderer
def execute(events, atom_request: false)
- events.map(&:note).compact.group_by(&:project).each do |project, notes|
- render_notes(notes, project, atom_request)
- end
+ notes = events.map(&:note).compact
+
+ render_notes(notes, atom_request)
end
private
- def render_notes(notes, project, atom_request)
- Notes::RenderService.new(current_user).execute(notes, project, render_options(atom_request))
+ def render_notes(notes, atom_request)
+ Notes::RenderService
+ .new(current_user)
+ .execute(notes, render_options(atom_request))
end
def render_options(atom_request)
diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb
index c57a2445341..fe1ac70781e 100644
--- a/app/services/merge_requests/create_service.rb
+++ b/app/services/merge_requests/create_service.rb
@@ -71,8 +71,8 @@ module MergeRequests
params.delete(:source_project_id)
params.delete(:target_project_id)
- unless can?(current_user, :read_project, @source_project) &&
- can?(current_user, :read_project, @project)
+ unless can?(current_user, :create_merge_request_from, @source_project) &&
+ can?(current_user, :create_merge_request_in, @project)
raise Gitlab::Access::AccessDeniedError
end
diff --git a/app/services/notes/render_service.rb b/app/services/notes/render_service.rb
index a77e98c2b07..efc9d6da2aa 100644
--- a/app/services/notes/render_service.rb
+++ b/app/services/notes/render_service.rb
@@ -3,19 +3,18 @@ module Notes
# Renders a collection of Note instances.
#
# notes - The notes to render.
- # project - The project to use for redacting.
- # user - The user viewing the notes.
-
+ #
# Possible options:
+ #
# requested_path - The request path.
# project_wiki - The project's wiki.
# ref - The current Git reference.
# only_path - flag to turn relative paths into absolute ones.
# xhtml - flag to save the html in XHTML
- def execute(notes, project, **opts)
- renderer = Banzai::ObjectRenderer.new(project, current_user, **opts)
-
- renderer.render(notes, :note)
+ def execute(notes, options = {})
+ Banzai::ObjectRenderer
+ .new(user: current_user, redaction_context: options)
+ .render(notes, :note)
end
end
end
diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml
index 09652054d09..2a809b9f772 100644
--- a/app/views/admin/projects/show.html.haml
+++ b/app/views/admin/projects/show.html.haml
@@ -101,7 +101,7 @@
- if @project.archived?
%li
%span.light archived:
- %strong repository is read-only
+ %strong project is read-only
%li
%span.light access:
diff --git a/app/views/admin/users/_user.html.haml b/app/views/admin/users/_user.html.haml
index 0e9d236660c..2e57047b05d 100644
--- a/app/views/admin/users/_user.html.haml
+++ b/app/views/admin/users/_user.html.haml
@@ -33,7 +33,7 @@
= link_to 'Block', block_admin_user_path(user), data: { confirm: 'USER WILL BE BLOCKED! Are you sure?' }, method: :put
- if user.access_locked?
%li
- = link_to 'Unlock', unlock_admin_user_path(user), method: :put, class: 'btn-grouped btn btn-xs btn-success', data: { confirm: 'Are you sure?' }
+ = link_to _('Unlock'), unlock_admin_user_path(user), method: :put, data: { confirm: _('Are you sure?') }
- if can?(current_user, :destroy_user, user)
%li.divider
- if user.can_be_removed?
diff --git a/app/views/award_emoji/_awards_block.html.haml b/app/views/award_emoji/_awards_block.html.haml
index 5f07d2720c2..4b3c52af16a 100644
--- a/app/views/award_emoji/_awards_block.html.haml
+++ b/app/views/award_emoji/_awards_block.html.haml
@@ -3,13 +3,13 @@
.awards.js-awards-block{ class: ("hidden" if !inline && grouped_emojis.empty?), data: { award_url: toggle_award_url(awardable) } }
- awards_sort(grouped_emojis).each do |emoji, awards|
%button.btn.award-control.js-emoji-btn.has-tooltip{ type: "button",
- class: [(award_state_class(awards, current_user)), (award_user_authored_class(emoji) if user_authored)],
+ class: [(award_state_class(awardable, awards, current_user)), (award_user_authored_class(emoji) if user_authored)],
data: { placement: "bottom", title: award_user_list(awards, current_user) } }
= emoji_icon(emoji)
%span.award-control-text.js-counter
= awards.count
- - if current_user
+ - if can?(current_user, :award_emoji, awardable)
.award-menu-holder.js-award-holder
%button.btn.award-control.has-tooltip.js-add-award{ type: 'button',
'aria-label': 'Add reaction',
diff --git a/app/views/devise/shared/_tab_single.html.haml b/app/views/devise/shared/_tab_single.html.haml
index f943d25e41a..7bd414d64c3 100644
--- a/app/views/devise/shared/_tab_single.html.haml
+++ b/app/views/devise/shared/_tab_single.html.haml
@@ -1,3 +1,3 @@
-%ul.nav-links.nav-tabs.new-session-tabs.single-tab
+%ul.nav-links.new-session-tabs.single-tab
%li.active
%a= tab_title
diff --git a/app/views/devise/shared/_tabs_ldap.html.haml b/app/views/devise/shared/_tabs_ldap.html.haml
index 270191f9452..f50e0724e09 100644
--- a/app/views/devise/shared/_tabs_ldap.html.haml
+++ b/app/views/devise/shared/_tabs_ldap.html.haml
@@ -1,4 +1,4 @@
-%ul.new-session-tabs.nav-links.nav-tabs{ class: ('custom-provider-tabs' if form_based_providers.any?) }
+%ul.nav-links.new-session-tabs{ class: ('custom-provider-tabs' if form_based_providers.any?) }
- if crowd_enabled?
%li.active
= link_to "Crowd", "#crowd", 'data-toggle' => 'tab'
diff --git a/app/views/devise/shared/_tabs_normal.html.haml b/app/views/devise/shared/_tabs_normal.html.haml
index 1ba6d390875..fa3c3df7f60 100644
--- a/app/views/devise/shared/_tabs_normal.html.haml
+++ b/app/views/devise/shared/_tabs_normal.html.haml
@@ -1,4 +1,4 @@
-%ul.nav-links.new-session-tabs.nav-tabs{ role: 'tablist' }
+%ul.nav-links.new-session-tabs{ role: 'tablist' }
%li.active{ role: 'presentation' }
%a{ href: '#login-pane', data: { toggle: 'tab' }, role: 'tab' } Sign in
- if allow_signup?
diff --git a/app/views/layouts/header/_new_dropdown.haml b/app/views/layouts/header/_new_dropdown.haml
index eb32f393310..6f53f5ac1ae 100644
--- a/app/views/layouts/header/_new_dropdown.haml
+++ b/app/views/layouts/header/_new_dropdown.haml
@@ -19,8 +19,8 @@
%li.dropdown-bold-header GitLab
- if @project&.persisted?
- - create_project_issue = can?(current_user, :create_issue, @project)
- - merge_project = can?(current_user, :create_merge_request, @project) ? @project : (current_user && current_user.fork_of(@project))
+ - create_project_issue = show_new_issue_link?(@project)
+ - merge_project = merge_request_source_project_for_project(@project)
- create_project_snippet = can?(current_user, :create_project_snippet, @project)
- if create_project_issue || merge_project || create_project_snippet
%li.dropdown-bold-header This project
diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml
index a5d7ddc8d1f..668c209029a 100644
--- a/app/views/layouts/nav/sidebar/_project.html.haml
+++ b/app/views/layouts/nav/sidebar/_project.html.haml
@@ -13,7 +13,7 @@
.nav-icon-container
= sprite_icon('project')
%span.nav-item-name
- Overview
+ Project
%ul.sidebar-sub-level-items
= nav_link(path: 'projects#show', html_options: { class: "fly-out-top-item" } ) do
diff --git a/app/views/projects/_last_push.html.haml b/app/views/projects/_last_push.html.haml
index 77077b235ba..3b66fdbdf1a 100644
--- a/app/views/projects/_last_push.html.haml
+++ b/app/views/projects/_last_push.html.haml
@@ -13,6 +13,7 @@
#{time_ago_with_tooltip(event.created_at)}
- .flex-right
- = link_to new_mr_path_from_push_event(event), title: _("New merge request"), class: "btn btn-info btn-sm qa-create-merge-request" do
- #{ _('Create merge request') }
+ - if can?(current_user, :create_merge_request_in, event.project.default_merge_request_target)
+ .flex-right
+ = link_to new_mr_path_from_push_event(event), title: _("New merge request"), class: "btn btn-info btn-sm qa-create-merge-request" do
+ #{ _('Create merge request') }
diff --git a/app/views/projects/_visibility_select.html.haml b/app/views/projects/_visibility_select.html.haml
deleted file mode 100644
index 4026b9e3c46..00000000000
--- a/app/views/projects/_visibility_select.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-- if can_change_visibility_level?(@project, current_user)
- .select-wrapper
- = form.select(model_method, visibility_select_options(@project, selected_level), {}, class: 'form-control visibility-select select-control')
- = icon('chevron-down')
-- else
- .info.js-locked{ data: { help_block: visibility_level_description(@project.visibility_level, @project) } }
- = visibility_level_icon(@project.visibility_level)
- %strong
- = visibility_level_label(@project.visibility_level)
diff --git a/app/views/projects/branches/_branch.html.haml b/app/views/projects/branches/_branch.html.haml
index 483ddb28df4..016894577c0 100644
--- a/app/views/projects/branches/_branch.html.haml
+++ b/app/views/projects/branches/_branch.html.haml
@@ -4,7 +4,7 @@
- diverging_commit_counts = @repository.diverging_commit_counts(branch)
- number_commits_behind = diverging_commit_counts[:behind]
- number_commits_ahead = diverging_commit_counts[:ahead]
-- merge_project = can?(current_user, :create_merge_request, @project) ? @project : (current_user && current_user.fork_of(@project))
+- merge_project = merge_request_source_project_for_project(@project)
%li{ class: "branch-item js-branch-#{branch.name}" }
.branch-info
.branch-title
@@ -61,7 +61,7 @@
title: s_('Branches|The default branch cannot be deleted') }
= icon("trash-o")
- elsif protected_branch?(@project, branch)
- - if can?(current_user, :delete_protected_branch, @project)
+ - if can?(current_user, :push_to_delete_protected_branch, @project)
%button{ class: "btn btn-remove remove-row js-ajax-loading-spinner has-tooltip",
title: s_('Branches|Delete protected branch'),
data: { toggle: "modal",
diff --git a/app/views/projects/buttons/_dropdown.html.haml b/app/views/projects/buttons/_dropdown.html.haml
index 18e948ce35a..2e86a7d36d7 100644
--- a/app/views/projects/buttons/_dropdown.html.haml
+++ b/app/views/projects/buttons/_dropdown.html.haml
@@ -1,13 +1,17 @@
-- if current_user
+- can_create_issue = show_new_issue_link?(@project)
+- can_create_project_snippet = can?(current_user, :create_project_snippet, @project)
+- can_push_code = can?(current_user, :push_code, @project)
+- create_mr_from_new_fork = can?(current_user, :fork_project, @project) && can?(current_user, :create_merge_request_in, @project)
+- merge_project = merge_request_source_project_for_project(@project)
+
+- show_menu = can_create_issue || can_create_project_snippet || can_push_code || create_mr_from_new_fork || merge_project
+
+- if show_menu
.project-action-button.dropdown.inline
%a.btn.dropdown-toggle.has-tooltip{ href: '#', title: _('Create new...'), 'data-toggle' => 'dropdown', 'data-container' => 'body', 'aria-label' => _('Create new...') }
= icon('plus')
= icon("caret-down")
%ul.dropdown-menu.dropdown-menu-align-right.project-home-dropdown
- - can_create_issue = can?(current_user, :create_issue, @project)
- - merge_project = can?(current_user, :create_merge_request, @project) ? @project : (current_user && current_user.fork_of(@project))
- - can_create_project_snippet = can?(current_user, :create_project_snippet, @project)
-
- if can_create_issue || merge_project || can_create_project_snippet
%li.dropdown-header= _('This project')
@@ -20,17 +24,17 @@
- if can_create_project_snippet
%li= link_to _('New snippet'), new_project_snippet_path(@project)
- - if can?(current_user, :push_code, @project)
+ - if can_push_code
%li.dropdown-header= _('This repository')
- - if can?(current_user, :push_code, @project)
+ - if can_push_code
%li= link_to _('New file'), project_new_blob_path(@project, @project.default_branch || 'master')
- unless @project.empty_repo?
%li= link_to _('New branch'), new_project_branch_path(@project)
%li= link_to _('New tag'), new_project_tag_path(@project)
- - elsif current_user && current_user.already_forked?(@project)
+ - elsif can_collaborate_with_project?(@project)
%li= link_to _('New file'), project_new_blob_path(@project, @project.default_branch || 'master')
- - elsif can?(current_user, :fork_project, @project)
+ - elsif create_mr_from_new_fork
- continue_params = { to: project_new_blob_path(@project, @project.default_branch || 'master'),
notice: edit_in_new_fork_notice,
notice_now: edit_in_new_fork_notice_now }
diff --git a/app/views/projects/clusters/_empty_state.html.haml b/app/views/projects/clusters/_empty_state.html.haml
index 30313e62de1..b8a3556a206 100644
--- a/app/views/projects/clusters/_empty_state.html.haml
+++ b/app/views/projects/clusters/_empty_state.html.haml
@@ -7,5 +7,6 @@
- link_to_help_page = link_to(_('Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
%p= s_('ClusterIntegration|Kubernetes clusters allow you to use review apps, deploy your applications, run your pipelines, and much more in an easy way. %{link_to_help_page}').html_safe % { link_to_help_page: link_to_help_page}
- .text-center
- = link_to s_('ClusterIntegration|Add Kubernetes cluster'), new_project_cluster_path(@project), class: 'btn btn-success'
+ - if can?(current_user, :create_cluster, @project)
+ .text-center
+ = link_to s_('ClusterIntegration|Add Kubernetes cluster'), new_project_cluster_path(@project), class: 'btn btn-success'
diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml
index a663434e990..715cab3d766 100644
--- a/app/views/projects/commit/_commit_box.html.haml
+++ b/app/views/projects/commit/_commit_box.html.haml
@@ -1,3 +1,5 @@
+- can_collaborate = can_collaborate_with_project?(@project)
+
.page-content-header.js-commit-box{ 'data-commit-path' => branches_project_commit_path(@project, @commit.id) }
.header-main-content
= render partial: 'signature', object: @commit.signature
@@ -32,12 +34,13 @@
%li.d-block.d-sm-none.d-md-none
= link_to project_tree_path(@project, @commit) do
#{ _('Browse Files') }
- - unless @commit.has_been_reverted?(current_user)
+ - if can_collaborate && !@commit.has_been_reverted?(current_user)
%li.clearfix
= revert_commit_link(@commit, project_commit_path(@project, @commit.id), has_tooltip: false)
- %li.clearfix
- = cherry_pick_commit_link(@commit, project_commit_path(@project, @commit.id), has_tooltip: false)
- - if can_collaborate_with_project?
+ - if can_collaborate
+ %li.clearfix
+ = cherry_pick_commit_link(@commit, project_commit_path(@project, @commit.id), has_tooltip: false)
+ - if can?(current_user, :push_code, @project)
%li.clearfix
= link_to s_("CreateTag|Tag"), new_project_tag_path(@project, ref: @commit)
%li.divider
diff --git a/app/views/projects/commit/show.html.haml b/app/views/projects/commit/show.html.haml
index abb292f8f27..541ae905246 100644
--- a/app/views/projects/commit/show.html.haml
+++ b/app/views/projects/commit/show.html.haml
@@ -17,6 +17,6 @@
.limited-width-notes
= render "shared/notes/notes_with_form", :autocomplete => true
- - if can_collaborate_with_project?
+ - if can_collaborate_with_project?(@project)
- %w(revert cherry-pick).each do |type|
= render "projects/commit/change", type: type, commit: @commit, title: @commit.title
diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml
index 59b04640ffe..e2ed3d79dbe 100644
--- a/app/views/projects/commits/_commit.html.haml
+++ b/app/views/projects/commits/_commit.html.haml
@@ -5,6 +5,7 @@
- link = commit_path(project, commit, merge_request: merge_request)
- cache_key = [project.full_path,
+ ref,
commit.id,
Gitlab::CurrentSettings.current_application_settings,
@path.presence,
@@ -54,7 +55,7 @@
- if commit.status(ref)
= render_commit_status(commit, ref: ref)
- .js-commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id) } }
+ .js-commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id, ref: ref) } }
.commit-sha-group
.label.label-monospace
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index ad5608aa11c..9a6c8820eb6 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -114,17 +114,18 @@
Archive project
- if @project.archived?
%p
- Unarchiving the project will mark its repository as active. The project can be committed to.
+ Unarchiving the project will restore people's ability to make changes to it.
+ The repository can be committed to, and issues, comments and other entities can be created.
%strong Once active this project shows up in the search and on the dashboard.
= link_to 'Unarchive project', unarchive_project_path(@project),
- data: { confirm: "Are you sure that you want to unarchive this project?\nWhen this project is unarchived it is active and can be committed to again." },
+ data: { confirm: "Are you sure that you want to unarchive this project?" },
method: :post, class: "btn btn-success"
- else
%p
- Archiving the project will mark its repository as read-only. It is hidden from the dashboard and doesn't show up in searches.
- %strong Archived projects cannot be committed to!
+ Archiving the project will make it entirely read-only. It is hidden from the dashboard and doesn't show up in searches.
+ %strong The repository cannot be committed to, and no issues, comments or other entities can be created.
= link_to 'Archive project', archive_project_path(@project),
- data: { confirm: "Are you sure that you want to archive this project?\nAn archived project cannot be committed to." },
+ data: { confirm: "Are you sure that you want to archive this project?" },
method: :post, class: "btn btn-warning"
.sub-section.rename-respository
%h4.warning-title
diff --git a/app/views/projects/issues/_nav_btns.html.haml b/app/views/projects/issues/_nav_btns.html.haml
index 0a37f2ae02f..ba75a6b0e29 100644
--- a/app/views/projects/issues/_nav_btns.html.haml
+++ b/app/views/projects/issues/_nav_btns.html.haml
@@ -2,9 +2,10 @@
= icon('rss')
- if @can_bulk_update
= button_tag "Edit issues", class: "btn btn-secondary append-right-10 js-bulk-update-toggle"
-= link_to "New issue", new_project_issue_path(@project,
- issue: { assignee_id: finder.assignee.try(:id),
- milestone_id: finder.milestones.first.try(:id) }),
- class: "btn btn-new",
- title: "New issue",
- id: "new_issue_link"
+- if show_new_issue_link?(@project)
+ = link_to "New issue", new_project_issue_path(@project,
+ issue: { assignee_id: finder.assignee.try(:id),
+ milestone_id: finder.milestones.first.try(:id) }),
+ class: "btn btn-new",
+ title: "New issue",
+ id: "new_issue_link"
diff --git a/app/views/projects/issues/_new_branch.html.haml b/app/views/projects/issues/_new_branch.html.haml
index 5bb048a7372..401a40e8d4a 100644
--- a/app/views/projects/issues/_new_branch.html.haml
+++ b/app/views/projects/issues/_new_branch.html.haml
@@ -1,8 +1,8 @@
-- can_create_merge_request = can?(current_user, :create_merge_request, @project)
-- data_action = can_create_merge_request ? 'create-mr' : 'create-branch'
-- value = can_create_merge_request ? 'Create merge request' : 'Create branch'
-
- if can?(current_user, :push_code, @project)
+ - can_create_merge_request = can?(current_user, :create_merge_request_in, @project)
+ - data_action = can_create_merge_request ? 'create-mr' : 'create-branch'
+ - value = can_create_merge_request ? 'Create merge request' : 'Create branch'
+
- can_create_path = can_create_branch_project_issue_path(@project, @issue)
- create_mr_path = create_merge_request_project_issue_path(@project, @issue, branch_name: @issue.to_branch_name, ref: @project.default_branch)
- create_branch_path = project_branches_path(@project, branch_name: @issue.to_branch_name, ref: @project.default_branch, issue_iid: @issue.iid)
diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index 7a4980b2afd..733c9c635ff 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -7,6 +7,7 @@
- can_update_issue = can?(current_user, :update_issue, @issue)
- can_report_spam = @issue.submittable_as_spam_by?(current_user)
+- can_create_issue = show_new_issue_link?(@project)
.detail-page-header
.detail-page-header-body
@@ -42,16 +43,18 @@
%li= link_to 'Reopen issue', issue_path(@issue, issue: { state_event: :reopen }, format: 'json'), class: "btn-reopen js-btn-issue-action #{issue_button_visibility(@issue, false)}", title: 'Reopen issue'
- if can_report_spam
%li= link_to 'Submit as spam', mark_as_spam_project_issue_path(@project, @issue), method: :post, class: 'btn-spam', title: 'Submit as spam'
- - if can_update_issue || can_report_spam
- %li.divider
- %li= link_to 'New issue', new_project_issue_path(@project), title: 'New issue', id: 'new_issue_link'
+ - if can_create_issue
+ - if can_update_issue || can_report_spam
+ %li.divider
+ %li= link_to 'New issue', new_project_issue_path(@project), title: 'New issue', id: 'new_issue_link'
= render 'shared/issuable/close_reopen_button', issuable: @issue, can_update: can_update_issue
- if can_report_spam
= link_to 'Submit as spam', mark_as_spam_project_issue_path(@project, @issue), method: :post, class: 'd-none d-sm-none d-md-block btn btn-grouped btn-spam', title: 'Submit as spam'
- = link_to new_project_issue_path(@project), class: 'd-none d-sm-none d-md-block btn btn-grouped new-issue-link btn-new btn-inverted', title: 'New issue', id: 'new_issue_link' do
- New issue
+ - if can_create_issue
+ = link_to new_project_issue_path(@project), class: 'd-none d-sm-none d-md-block btn btn-grouped new-issue-link btn-new btn-inverted', title: 'New issue', id: 'new_issue_link' do
+ New issue
.issue-details.issuable-details
.detail-page-description.content-block
diff --git a/app/views/projects/jobs/show.html.haml b/app/views/projects/jobs/show.html.haml
index 27f47e581bb..500b5890e84 100644
--- a/app/views/projects/jobs/show.html.haml
+++ b/app/views/projects/jobs/show.html.haml
@@ -55,7 +55,7 @@
- else
Job has been erased #{time_ago_with_tooltip(@build.erased_at)}
- - if @build.has_trace?
+ - if @build.running? || @build.has_trace?
.build-trace-container.prepend-top-default
.top-bar.js-top-bar
.js-truncated-info.truncated-info.d-none.d-sm-block.float-left.hidden<
diff --git a/app/views/projects/merge_requests/index.html.haml b/app/views/projects/merge_requests/index.html.haml
index b2c0d9e1cfa..623380c9c61 100644
--- a/app/views/projects/merge_requests/index.html.haml
+++ b/app/views/projects/merge_requests/index.html.haml
@@ -1,6 +1,6 @@
- @no_container = true
- @can_bulk_update = can?(current_user, :admin_merge_request, @project)
-- merge_project = can?(current_user, :create_merge_request, @project) ? @project : (current_user && current_user.fork_of(@project))
+- merge_project = merge_request_source_project_for_project(@project)
- new_merge_request_path = project_new_merge_request_path(merge_project) if merge_project
- page_title "Merge Requests"
diff --git a/app/views/projects/notes/_actions.html.haml b/app/views/projects/notes/_actions.html.haml
index 5ea653ccad5..b4fe1cabdfd 100644
--- a/app/views/projects/notes/_actions.html.haml
+++ b/app/views/projects/notes/_actions.html.haml
@@ -36,7 +36,7 @@
%template{ 'v-else' => '' }
= render 'shared/icons/icon_resolve_discussion.svg'
-- if current_user
+- if can?(current_user, :award_emoji, note)
- if note.emoji_awardable?
- user_authored = note.user_authored?(current_user)
.note-actions-item
diff --git a/app/views/projects/protected_branches/shared/_branches_list.html.haml b/app/views/projects/protected_branches/shared/_branches_list.html.haml
index 5d774e1a91f..e19dea69b51 100644
--- a/app/views/projects/protected_branches/shared/_branches_list.html.haml
+++ b/app/views/projects/protected_branches/shared/_branches_list.html.haml
@@ -1,4 +1,4 @@
-.card.protected-branches-list.js-protected-branches-list
+.protected-branches-list.js-protected-branches-list
- if @protected_branches.empty?
.card-header
%h3.card-title
diff --git a/app/views/projects/protected_tags/shared/_tags_list.html.haml b/app/views/projects/protected_tags/shared/_tags_list.html.haml
index 1b333fe5287..c3081d75fb4 100644
--- a/app/views/projects/protected_tags/shared/_tags_list.html.haml
+++ b/app/views/projects/protected_tags/shared/_tags_list.html.haml
@@ -1,4 +1,4 @@
-.card.protected-tags-list.js-protected-tags-list
+.protected-tags-list.js-protected-tags-list
- if @protected_tags.empty?
.card-header
%h3.card-title
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index 94331a16abd..e28accd5b43 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -24,7 +24,7 @@
.text-warning.center.prepend-top-20
%p
= icon("exclamation-triangle fw")
- #{ _('Archived project! Repository is read-only') }
+ #{ _('Archived project! Repository and other project resources are read-only') }
- view_path = @project.default_view
diff --git a/app/views/projects/tags/_tag.html.haml b/app/views/projects/tags/_tag.html.haml
index 3d5f92f9aaa..98b4d6339da 100644
--- a/app/views/projects/tags/_tag.html.haml
+++ b/app/views/projects/tags/_tag.html.haml
@@ -31,6 +31,6 @@
= link_to edit_project_tag_release_path(@project, tag.name), class: 'btn has-tooltip', title: s_('TagsPage|Edit release notes'), data: { container: "body" } do
= icon("pencil")
- - if can?(current_user, :admin_project, @project)
- = link_to project_tag_path(@project, tag.name), class: "btn btn-remove remove-row has-tooltip prepend-left-10 #{protected_tag?(@project, tag) ? 'disabled' : ''}", title: s_('TagsPage|Delete tag'), method: :delete, data: { confirm: s_('TagsPage|Deleting the %{tag_name} tag cannot be undone. Are you sure?') % { tag_name: tag.name }, container: 'body' }, remote: true do
- = icon("trash-o")
+ - if can?(current_user, :admin_project, @project)
+ = link_to project_tag_path(@project, tag.name), class: "btn btn-remove remove-row has-tooltip prepend-left-10 #{protected_tag?(@project, tag) ? 'disabled' : ''}", title: s_('TagsPage|Delete tag'), method: :delete, data: { confirm: s_('TagsPage|Deleting the %{tag_name} tag cannot be undone. Are you sure?') % { tag_name: tag.name }, container: 'body' }, remote: true do
+ = icon("trash-o")
diff --git a/app/views/projects/tags/show.html.haml b/app/views/projects/tags/show.html.haml
index dfe2c37ed8e..7a3469cdd26 100644
--- a/app/views/projects/tags/show.html.haml
+++ b/app/views/projects/tags/show.html.haml
@@ -28,7 +28,7 @@
= icon('history')
.btn-container.controls-item
= render 'projects/buttons/download', project: @project, ref: @tag.name
- - if can?(current_user, :admin_project, @project)
+ - if can?(current_user, :push_code, @project) && can?(current_user, :admin_project, @project)
.btn-container.controls-item-full
= link_to project_tag_path(@project, @tag.name), class: "btn btn-remove remove-row has-tooltip #{protected_tag?(@project, @tag) ? 'disabled' : ''}", title: s_('TagsPage|Delete tag'), method: :delete, data: { confirm: s_('TagsPage|Deleting the %{tag_name} tag cannot be undone. Are you sure?') % { tag_name: @tag.name } } do
%i.fa.fa-trash-o
diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml
index 0f1242455b2..0987392b8e1 100644
--- a/app/views/projects/tree/_tree_header.html.haml
+++ b/app/views/projects/tree/_tree_header.html.haml
@@ -1,3 +1,6 @@
+- can_collaborate = can_collaborate_with_project?(@project)
+- can_create_mr_from_fork = can?(current_user, :fork_project, @project) && can?(current_user, :create_merge_request_in, @project)
+
.tree-ref-container
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'tree', path: @path, show_create: true
@@ -15,7 +18,7 @@
%li.breadcrumb-item
= link_to truncate(title, length: 40), project_tree_path(@project, tree_join(@ref, path))
- - if current_user
+ - if can_collaborate || can_create_mr_from_fork
%li.breadcrumb-item
%a.btn.add-to-tree{ addtotree_toggle_attributes }
= sprite_icon('plus', size: 16, css_class: 'float-left')
@@ -35,7 +38,7 @@
%li
= link_to '#modal-create-new-dir', { 'data-target' => '#modal-create-new-dir', 'data-toggle' => 'modal' } do
#{ _('New directory') }
- - elsif can?(current_user, :fork_project, @project)
+ - elsif can?(current_user, :fork_project, @project) && can?(current_user, :create_merge_request_in, @project)
%li
- continue_params = { to: project_new_blob_path(@project, @id),
notice: edit_in_new_fork_notice,
@@ -61,23 +64,25 @@
= link_to fork_path, method: :post do
#{ _('New directory') }
- %li.divider
- %li.dropdown-header
- #{ _('This repository') }
- %li
- = link_to new_project_branch_path(@project) do
- #{ _('New branch') }
- %li
- = link_to new_project_tag_path(@project) do
- #{ _('New tag') }
+ - if can?(current_user, :push_code, @project)
+ %li.divider
+ %li.dropdown-header
+ #{ _('This repository') }
+ %li
+ = link_to new_project_branch_path(@project) do
+ #{ _('New branch') }
+ %li
+ = link_to new_project_tag_path(@project) do
+ #{ _('New tag') }
.tree-controls
= link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn'
= render 'projects/find_file_link'
- = succeed " " do
- = link_to ide_edit_path(@project, @id, ""), class: 'btn btn-secondary' do
- = _('Web IDE')
+ - if can_collaborate
+ = succeed " " do
+ = link_to ide_edit_path(@project, @id, ""), class: 'btn btn-secondary' do
+ = _('Web IDE')
= render 'projects/buttons/download', project: @project, ref: @ref
diff --git a/app/views/shared/_label.html.haml b/app/views/shared/_label.html.haml
index cdc991c9cd1..298a15a3a25 100644
--- a/app/views/shared/_label.html.haml
+++ b/app/views/shared/_label.html.haml
@@ -47,20 +47,20 @@
class: 'text-danger'
.float-right.d-none.d-sm-none.d-md-block
- - if label.is_a?(ProjectLabel) && label.project.group && can?(current_user, :admin_label, label.project.group)
- %button.js-promote-project-label-button.btn.btn-transparent.btn-action.has-tooltip{ title: _('Promote to Group Label'),
- disabled: true,
- type: 'button',
- data: { url: promote_project_label_path(label.project, label),
- label_title: label.title,
- label_color: label.color,
- label_text_color: label.text_color,
- group_name: label.project.group.name,
- target: '#promote-label-modal',
- container: 'body',
- toggle: 'modal' } }
- = sprite_icon('level-up')
- if can?(current_user, :admin_label, label)
+ - if label.is_a?(ProjectLabel) && label.project.group && can?(current_user, :admin_label, label.project.group)
+ %button.js-promote-project-label-button.btn.btn-transparent.btn-action.has-tooltip{ title: _('Promote to Group Label'),
+ disabled: true,
+ type: 'button',
+ data: { url: promote_project_label_path(label.project, label),
+ label_title: label.title,
+ label_color: label.color,
+ label_text_color: label.text_color,
+ group_name: label.project.group.name,
+ target: '#promote-label-modal',
+ container: 'body',
+ toggle: 'modal' } }
+ = sprite_icon('level-up')
= link_to edit_label_path(label), title: "Edit", class: 'btn btn-transparent btn-action', data: {toggle: "tooltip"} do
%span.sr-only Edit
= sprite_icon('pencil')
diff --git a/app/views/shared/milestones/_sidebar.html.haml b/app/views/shared/milestones/_sidebar.html.haml
index a710d06f076..d0676cda2f9 100644
--- a/app/views/shared/milestones/_sidebar.html.haml
+++ b/app/views/shared/milestones/_sidebar.html.haml
@@ -71,8 +71,8 @@
%span= milestone.issues_visible_to_user(current_user).count
.title.hide-collapsed
Issues
- %span.badge.badge-pill= milestone.issues_visible_to_user(current_user).count
- - if project && can?(current_user, :create_issue, project)
+ %span.badg.badge-pille= milestone.issues_visible_to_user(current_user).count
+ - if show_new_issue_link?(project)
= link_to new_project_issue_path(project, issue: { milestone_id: milestone.id }), class: "float-right", title: "New Issue" do
New issue
.value.hide-collapsed.bold
diff --git a/app/views/shared/notes/_form.html.haml b/app/views/shared/notes/_form.html.haml
index 725bf916592..71c0d740bc8 100644
--- a/app/views/shared/notes/_form.html.haml
+++ b/app/views/shared/notes/_form.html.haml
@@ -24,20 +24,21 @@
-# DiffNote
= f.hidden_field :position
- = render layout: 'projects/md_preview', locals: { url: preview_url, referenced_users: true } do
- = render 'projects/zen', f: f,
- attr: :note,
- classes: 'note-textarea js-note-text',
- placeholder: "Write a comment or drag your files here...",
- supports_quick_actions: supports_quick_actions,
- supports_autocomplete: supports_autocomplete
- = render 'shared/notes/hints', supports_quick_actions: supports_quick_actions
- .error-alert
-
- .note-form-actions.clearfix
- = render partial: 'shared/notes/comment_button'
-
- = yield(:note_actions)
-
- %a.btn.btn-cancel.js-note-discard{ role: "button", data: {cancel_text: "Cancel" } }
- Discard draft
+ .discussion-form-container
+ = render layout: 'projects/md_preview', locals: { url: preview_url, referenced_users: true } do
+ = render 'projects/zen', f: f,
+ attr: :note,
+ classes: 'note-textarea js-note-text',
+ placeholder: "Write a comment or drag your files here...",
+ supports_quick_actions: supports_quick_actions,
+ supports_autocomplete: supports_autocomplete
+ = render 'shared/notes/hints', supports_quick_actions: supports_quick_actions
+ .error-alert
+
+ .note-form-actions.clearfix
+ = render partial: 'shared/notes/comment_button'
+
+ = yield(:note_actions)
+
+ %a.btn.btn-cancel.js-note-discard{ role: "button", data: {cancel_text: "Cancel" } }
+ Discard draft
diff --git a/app/views/shared/notes/_note.html.haml b/app/views/shared/notes/_note.html.haml
index 4c282759493..ed0167dbf42 100644
--- a/app/views/shared/notes/_note.html.haml
+++ b/app/views/shared/notes/_note.html.haml
@@ -2,7 +2,7 @@
- return if note.cross_reference_not_visible_for?(current_user)
- show_image_comment_badge = local_assigns.fetch(:show_image_comment_badge, false)
-- note_editable = note_editable?(note)
+- note_editable = can?(current_user, :admin_note, note)
- note_counter = local_assigns.fetch(:note_counter, 0)
%li.timeline-entry{ id: dom_id(note),
diff --git a/bin/spinach b/bin/spinach
index 474050e29d1..eda81c9ed8a 100755
--- a/bin/spinach
+++ b/bin/spinach
@@ -1,4 +1,9 @@
#!/usr/bin/env ruby
+
+# Remove this block when removing rails5? code.
+gemfile = %w[1 true].include?(ENV["RAILS5"]) ? "Gemfile.rails5" : "Gemfile"
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../#{gemfile}", __dir__)
+
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
diff --git a/changelogs/unreleased/40487-axios-pipelines.yml b/changelogs/unreleased/40487-axios-pipelines.yml
new file mode 100644
index 00000000000..437d5e87e1a
--- /dev/null
+++ b/changelogs/unreleased/40487-axios-pipelines.yml
@@ -0,0 +1,4 @@
+title: Replace vue resource with axios in pipelines table
+merge_request:
+author:
+type: other \ No newline at end of file
diff --git a/changelogs/unreleased/41436-use-simpler-env-vars-for-auto-devops-replicas.yml b/changelogs/unreleased/41436-use-simpler-env-vars-for-auto-devops-replicas.yml
new file mode 100644
index 00000000000..ea007670332
--- /dev/null
+++ b/changelogs/unreleased/41436-use-simpler-env-vars-for-auto-devops-replicas.yml
@@ -0,0 +1,5 @@
+---
+title: 'Introduce simpler env vars for auto devops REPLICAS and CANARY_REPLICAS #41436'
+merge_request: 18036
+author:
+type: added
diff --git a/changelogs/unreleased/41748-vertical-misalignment-login-box.yml b/changelogs/unreleased/41748-vertical-misalignment-login-box.yml
new file mode 100644
index 00000000000..77a97400323
--- /dev/null
+++ b/changelogs/unreleased/41748-vertical-misalignment-login-box.yml
@@ -0,0 +1,5 @@
+---
+title: Refactor CSS to eliminate vertical misalignment of login nav
+merge_request: 16275
+author: Takuya Noguchi
+type: fixed
diff --git a/changelogs/unreleased/43794-fix-domain-verification-validation-errors.yml b/changelogs/unreleased/43794-fix-domain-verification-validation-errors.yml
deleted file mode 100644
index 861820c7538..00000000000
--- a/changelogs/unreleased/43794-fix-domain-verification-validation-errors.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Avoid validation errors when running the Pages domain verification service
-merge_request: 17992
-author:
-type: fixed
diff --git a/changelogs/unreleased/44541-fix-file-tree-commit-status-cache.yml b/changelogs/unreleased/44541-fix-file-tree-commit-status-cache.yml
new file mode 100644
index 00000000000..ff734fe0c05
--- /dev/null
+++ b/changelogs/unreleased/44541-fix-file-tree-commit-status-cache.yml
@@ -0,0 +1,5 @@
+---
+title: Fix pipeline status in branch/tag tree page
+merge_request: 17995
+author:
+type: fixed
diff --git a/changelogs/unreleased/44649-reference-parsing-conflicting-with-auto-linking.yml b/changelogs/unreleased/44649-reference-parsing-conflicting-with-auto-linking.yml
deleted file mode 100644
index a64b0efa1ed..00000000000
--- a/changelogs/unreleased/44649-reference-parsing-conflicting-with-auto-linking.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Fix autolinking URLs containing ampersands
-merge_request: 18045
-author:
-type: fixed
diff --git a/changelogs/unreleased/44697-prevue.yml b/changelogs/unreleased/44697-prevue.yml
new file mode 100644
index 00000000000..9fdce5869ae
--- /dev/null
+++ b/changelogs/unreleased/44697-prevue.yml
@@ -0,0 +1,5 @@
+---
+title: Make toggle markdown preview shortcut only toggle selected field
+merge_request:
+author:
+type: fixed
diff --git a/changelogs/unreleased/44717-no-resolve-issue.yml b/changelogs/unreleased/44717-no-resolve-issue.yml
deleted file mode 100644
index ce23f4e6e9f..00000000000
--- a/changelogs/unreleased/44717-no-resolve-issue.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Don't show Jump to Discussion button on Issues
-merge_request:
-author:
-type: fixed
diff --git a/changelogs/unreleased/44870-remove-extra-space-around-comment-form-on-merge-requests.yml b/changelogs/unreleased/44870-remove-extra-space-around-comment-form-on-merge-requests.yml
deleted file mode 100644
index 53e4ebdb996..00000000000
--- a/changelogs/unreleased/44870-remove-extra-space-around-comment-form-on-merge-requests.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Refactor and tweak margin for note forms on Issuable
-merge_request: 18120
-author: Takuya Noguchi
-type: fixed
diff --git a/changelogs/unreleased/45070-prometheus-integration-via-kubernetes-is-broken.yml b/changelogs/unreleased/45070-prometheus-integration-via-kubernetes-is-broken.yml
deleted file mode 100644
index 046785deb3f..00000000000
--- a/changelogs/unreleased/45070-prometheus-integration-via-kubernetes-is-broken.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Work around Prometheus Helm chart name changes to fix integration
-merge_request: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18206/
-author: joshlambert
-type: fixed
diff --git a/changelogs/unreleased/45159-fix-illustration.yml b/changelogs/unreleased/45159-fix-illustration.yml
new file mode 100644
index 00000000000..3b9cb45b916
--- /dev/null
+++ b/changelogs/unreleased/45159-fix-illustration.yml
@@ -0,0 +1,5 @@
+---
+title: Adds illustration for when job log was erased
+merge_request:
+author:
+type: fixed
diff --git a/changelogs/unreleased/45287-align-icons.yml b/changelogs/unreleased/45287-align-icons.yml
new file mode 100644
index 00000000000..0a1cccf9ca6
--- /dev/null
+++ b/changelogs/unreleased/45287-align-icons.yml
@@ -0,0 +1,5 @@
+---
+title: Align action icons in pipeline graph
+merge_request:
+author:
+type: fixed
diff --git a/changelogs/unreleased/ab-37125-assigned-issues-query.yml b/changelogs/unreleased/ab-37125-assigned-issues-query.yml
new file mode 100644
index 00000000000..5d4aad08764
--- /dev/null
+++ b/changelogs/unreleased/ab-37125-assigned-issues-query.yml
@@ -0,0 +1,5 @@
+---
+title: Reduce complexity of issuable finder query.
+merge_request: 18219
+author:
+type: performance
diff --git a/changelogs/unreleased/blackst0ne-replace-spinach-project-commits-branches-feature.yml b/changelogs/unreleased/blackst0ne-replace-spinach-project-commits-branches-feature.yml
new file mode 100644
index 00000000000..bcfba4ae70d
--- /dev/null
+++ b/changelogs/unreleased/blackst0ne-replace-spinach-project-commits-branches-feature.yml
@@ -0,0 +1,5 @@
+---
+title: "Replace the `project/commits/branches.feature` spinach test with an rspec analog"
+merge_request: 18302
+author: "@blackst0ne"
+type: other
diff --git a/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-milestones-feature.yml b/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-milestones-feature.yml
new file mode 100644
index 00000000000..0dcac0a80eb
--- /dev/null
+++ b/changelogs/unreleased/blackst0ne-replace-spinach-project-issues-milestones-feature.yml
@@ -0,0 +1,5 @@
+---
+title: Replace the `project/issues/milestones.feature` spinach test with an rspec analog
+merge_request: 18300
+author: "@blackst0ne"
+type: other
diff --git a/changelogs/unreleased/deploy-tokens-container-registry-specs.yml b/changelogs/unreleased/deploy-tokens-container-registry-specs.yml
new file mode 100644
index 00000000000..d86f955c966
--- /dev/null
+++ b/changelogs/unreleased/deploy-tokens-container-registry-specs.yml
@@ -0,0 +1,5 @@
+---
+title: Verify that deploy token has valid access when pulling container registry image
+merge_request: 18260
+author:
+type: fixed
diff --git a/changelogs/unreleased/dm-refs-contains-sha-encoding.yml b/changelogs/unreleased/dm-refs-contains-sha-encoding.yml
deleted file mode 100644
index cdd9ead5a65..00000000000
--- a/changelogs/unreleased/dm-refs-contains-sha-encoding.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Fix listing commit branch/tags that contain special characters
-merge_request:
-author:
-type: fixed
diff --git a/changelogs/unreleased/fix-gb-fix-background-pipeline-stages-migration.yml b/changelogs/unreleased/fix-gb-fix-background-pipeline-stages-migration.yml
deleted file mode 100644
index 63948f0c196..00000000000
--- a/changelogs/unreleased/fix-gb-fix-background-pipeline-stages-migration.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Fix exceptions raised when migrating pipeline stages in the background
-merge_request: 18076
-author:
-type: fixed
diff --git a/changelogs/unreleased/fix-wiki-find-file-gitaly.yml b/changelogs/unreleased/fix-wiki-find-file-gitaly.yml
new file mode 100644
index 00000000000..5c536be7ae5
--- /dev/null
+++ b/changelogs/unreleased/fix-wiki-find-file-gitaly.yml
@@ -0,0 +1,5 @@
+---
+title: Fix finding wiki file when Gitaly is enabled
+merge_request:
+author:
+type: fixed
diff --git a/changelogs/unreleased/fl-pipelines-details-axios.yml b/changelogs/unreleased/fl-pipelines-details-axios.yml
new file mode 100644
index 00000000000..0b72e54cba3
--- /dev/null
+++ b/changelogs/unreleased/fl-pipelines-details-axios.yml
@@ -0,0 +1,5 @@
+---
+title: Replace vue resource with axios for pipelines details page
+merge_request:
+author:
+type: other
diff --git a/changelogs/unreleased/improve-jobs-queuing-time-metric.yml b/changelogs/unreleased/improve-jobs-queuing-time-metric.yml
deleted file mode 100644
index cee8b8523fd..00000000000
--- a/changelogs/unreleased/improve-jobs-queuing-time-metric.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Partition job_queue_duration_seconds with jobs_running_for_project
-merge_request: 17730
-author:
-type: changed
diff --git a/changelogs/unreleased/issue_44551.yml b/changelogs/unreleased/issue_44551.yml
deleted file mode 100644
index d5265667b00..00000000000
--- a/changelogs/unreleased/issue_44551.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Fix 404 in group boards when moving issue between lists
-merge_request:
-author:
-type: fixed
diff --git a/changelogs/unreleased/jivl-change-copy-text-promote-milestones-labels.yml b/changelogs/unreleased/jivl-change-copy-text-promote-milestones-labels.yml
deleted file mode 100644
index fb3095552d3..00000000000
--- a/changelogs/unreleased/jivl-change-copy-text-promote-milestones-labels.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Correct copy text for the promote milestone and label modals
-merge_request: 17726
-author:
-type: fixed
diff --git a/changelogs/unreleased/move-estimate-only-pane-vue-component.yml b/changelogs/unreleased/move-estimate-only-pane-vue-component.yml
new file mode 100644
index 00000000000..b6c538f70b3
--- /dev/null
+++ b/changelogs/unreleased/move-estimate-only-pane-vue-component.yml
@@ -0,0 +1,5 @@
+---
+title: Move TimeTrackingEstimateOnlyPane vue component
+merge_request: 18318
+author: George Tsiolis
+type: performance
diff --git a/changelogs/unreleased/move-help-state-vue-component.yml b/changelogs/unreleased/move-help-state-vue-component.yml
new file mode 100644
index 00000000000..6108368cde0
--- /dev/null
+++ b/changelogs/unreleased/move-help-state-vue-component.yml
@@ -0,0 +1,5 @@
+---
+title: Move TimeTrackingHelpState vue component
+merge_request: 18319
+author: George Tsiolis
+type: performance
diff --git a/changelogs/unreleased/rename-overview-project-sidenav.yml b/changelogs/unreleased/rename-overview-project-sidenav.yml
new file mode 100644
index 00000000000..3632ef25c00
--- /dev/null
+++ b/changelogs/unreleased/rename-overview-project-sidenav.yml
@@ -0,0 +1,5 @@
+---
+title: Renamed Overview to Project in the contextual navigation at a project level
+merge_request: 18295
+author: Constance Okoghenun
+type: changed
diff --git a/changelogs/unreleased/rendering-markdown-multiple-projects.yml b/changelogs/unreleased/rendering-markdown-multiple-projects.yml
new file mode 100644
index 00000000000..8685772c089
--- /dev/null
+++ b/changelogs/unreleased/rendering-markdown-multiple-projects.yml
@@ -0,0 +1,5 @@
+---
+title: Support Markdown rendering using multiple projects
+merge_request:
+author:
+type: performance
diff --git a/changelogs/unreleased/sh-cleanup-pages-worker.yml b/changelogs/unreleased/sh-cleanup-pages-worker.yml
deleted file mode 100644
index c26e1342dd2..00000000000
--- a/changelogs/unreleased/sh-cleanup-pages-worker.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Free open file descriptors and libgit2 buffers in UpdatePagesService
-merge_request:
-author:
-type: performance
diff --git a/changelogs/unreleased/unresolved-discussions-vue-component-i18n-and-tests.yml b/changelogs/unreleased/unresolved-discussions-vue-component-i18n-and-tests.yml
new file mode 100644
index 00000000000..d99a9c93c0b
--- /dev/null
+++ b/changelogs/unreleased/unresolved-discussions-vue-component-i18n-and-tests.yml
@@ -0,0 +1,5 @@
+---
+title: Add i18n and update specs for UnresolvedDiscussions vue component
+merge_request: 17866
+author: George Tsiolis
+type: performance
diff --git a/changelogs/unreleased/winh-dropdown-entry-unlocking.yml b/changelogs/unreleased/winh-dropdown-entry-unlocking.yml
new file mode 100644
index 00000000000..fc669af1f57
--- /dev/null
+++ b/changelogs/unreleased/winh-dropdown-entry-unlocking.yml
@@ -0,0 +1,5 @@
+---
+title: Remove green background from unlock button in admin area
+merge_request: 18288
+author:
+type: changed
diff --git a/changelogs/unreleased/zj-branch-containing-sha-opt-out.yml b/changelogs/unreleased/zj-branch-containing-sha-opt-out.yml
new file mode 100644
index 00000000000..3d11ee588ae
--- /dev/null
+++ b/changelogs/unreleased/zj-branch-containing-sha-opt-out.yml
@@ -0,0 +1,5 @@
+---
+title: Detecting branchnames containing a commit uses Gitaly by default
+merge_request:
+author:
+type: performance
diff --git a/changelogs/unreleased/zj-tag-containing-sha-opt-out.yml b/changelogs/unreleased/zj-tag-containing-sha-opt-out.yml
new file mode 100644
index 00000000000..4774c7811d1
--- /dev/null
+++ b/changelogs/unreleased/zj-tag-containing-sha-opt-out.yml
@@ -0,0 +1,5 @@
+---
+title: Detecting tags containing a commit uses Gitaly by default
+merge_request:
+author:
+type: performance
diff --git a/config/karma.config.js b/config/karma.config.js
index c378e621953..61f02294157 100644
--- a/config/karma.config.js
+++ b/config/karma.config.js
@@ -1,5 +1,6 @@
var path = require('path');
var webpack = require('webpack');
+var argumentsParser = require('commander');
var webpackConfig = require('./webpack.config.js');
var ROOT_PATH = path.resolve(__dirname, '..');
@@ -14,6 +15,24 @@ if (webpackConfig.plugins) {
});
}
+var testFiles = argumentsParser
+ .option(
+ '-f, --filter-spec [filter]',
+ 'Filter run spec files by path. Multiple filters are like a logical OR.',
+ (val, memo) => {
+ memo.push(val);
+ return memo;
+ },
+ []
+ )
+ .parse(process.argv).filterSpec;
+
+webpackConfig.plugins.push(
+ new webpack.DefinePlugin({
+ 'process.env.TEST_FILES': JSON.stringify(testFiles),
+ })
+);
+
webpackConfig.devtool = 'cheap-inline-source-map';
// Karma configuration
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb
index dfb50c195c1..1e260236dc5 100644
--- a/db/fixtures/development/01_admin.rb
+++ b/db/fixtures/development/01_admin.rb
@@ -1,14 +1,14 @@
require './spec/support/sidekiq'
Gitlab::Seeder.quiet do
- User.seed do |s|
- s.id = 1
- s.name = 'Administrator'
- s.email = 'admin@example.com'
- s.notification_email = 'admin@example.com'
- s.username = 'root'
- s.password = '5iveL!fe'
- s.admin = true
- s.confirmed_at = DateTime.now
- end
+ User.create!(
+ name: 'Administrator',
+ email: 'admin@example.com',
+ username: 'root',
+ password: '5iveL!fe',
+ admin: true,
+ confirmed_at: DateTime.now
+ )
+
+ print '.'
end
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 30244ee4431..bcfdd058a1c 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -4,7 +4,7 @@ Gitlab::Seeder.quiet do
# Limit the number of merge requests per project to avoid long seeds
MAX_NUM_MERGE_REQUESTS = 10
- Project.all.reject(&:empty_repo?).each do |project|
+ Project.non_archived.with_merge_requests_enabled.reject(&:empty_repo?).each do |project|
branches = project.repository.branch_names.sample(MAX_NUM_MERGE_REQUESTS * 2)
branches.each do |branch_name|
@@ -21,7 +21,11 @@ Gitlab::Seeder.quiet do
assignee: project.team.users.sample
}
- MergeRequests::CreateService.new(project, project.team.users.sample, params).execute
+ # Only create MRs with users that are allowed to create MRs
+ developer = project.team.developers.sample
+ break unless developer
+
+ MergeRequests::CreateService.new(project, developer, params).execute
print '.'
end
end
diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb
index c1bbc9af6d6..00a14f458d1 100644
--- a/db/fixtures/development/19_environments.rb
+++ b/db/fixtures/development/19_environments.rb
@@ -28,7 +28,11 @@ class Gitlab::Seeder::Environments
end
def create_merge_request_review_deployments!
- @project.merge_requests.sample(4).map do |merge_request|
+ @project
+ .merge_requests
+ .select { |mr| mr.source_branch.match(/\p{Alnum}+/) }
+ .sample(4)
+ .each do |merge_request|
next unless merge_request.diff_head_sha
create_deployment!(
diff --git a/doc/README.md b/doc/README.md
index 604f7244a34..178e6567845 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -159,8 +159,12 @@ applications are always responsive and available. GitLab collects and displays
performance metrics for deployed apps using Prometheus so you can know in an
instant how code changes impact your production environment.
+- [GitLab Prometheus](administration/monitoring/prometheus/index.md): Configure the bundled Prometheus to collect various metrics from your GitLab instance.
+- [Prometheus project integration](user/project/integrations/prometheus.md): Configure the Prometheus integration per project and monitor your CI/CD environments.
+- [Prometheus metrics](user/project/integrations/prometheus_library/metrics.md): Let Prometheus collect metrics from various services, like Kubernetes, NGINX, NGINX ingress controller, HAProxy, and Amazon Cloud Watch.
+- [GitLab Performance Monitoring](administration/monitoring/performance/index.md): Use InfluxDB and Grafana to monitor the performance of your GitLab instance (will be eventually replaced by Prometheus).
+- [Health check](user/admin_area/monitoring/health_check.md): GitLab provides liveness and readiness probes to indicate service health and reachability to required services.
- [GitLab Cycle Analytics](user/project/cycle_analytics.md): Cycle Analytics measures the time it takes to go from an [idea to production](https://about.gitlab.com/2016/08/05/continuous-integration-delivery-and-deployment-with-gitlab/#from-idea-to-production-with-gitlab) for each project you have.
-- [GitLab Performance Monitoring](administration/monitoring/performance/index.md)
## Getting started with GitLab
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index 68aa64b3834..bd7ffb2befb 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -869,37 +869,29 @@ skip the download step.
- Introduced in GitLab Runner v0.7.0 for non-Windows platforms.
- Windows support was added in GitLab Runner v.1.0.0.
- From GitLab 9.2, caches are restored before artifacts.
-- Currently not all executors are supported.
+- Not all executors are [supported](https://docs.gitlab.com/runner/executors/#compatibility-chart).
- Job artifacts are only collected for successful jobs by default.
`artifacts` is used to specify a list of files and directories which should be
-attached to the job after success. You can only use paths that are within the
-project workspace. To pass artifacts between different jobs, see [dependencies](#dependencies).
-Below are some examples.
+attached to the job after success.
-Send all files in `binaries` and `.config`:
+The artifacts will be sent to GitLab after the job finishes successfully and will
+be available for download in the GitLab UI.
-```yaml
-artifacts:
- paths:
- - binaries/
- - .config
-```
+[Read more about artifacts.](../../user/project/pipelines/job_artifacts.md)
-Send all Git untracked files:
+### `artifacts:paths`
-```yaml
-artifacts:
- untracked: true
-```
+You can only use paths that are within the project workspace. To pass artifacts
+between different jobs, see [dependencies](#dependencies).
-Send all Git untracked files and files in `binaries`:
+Send all files in `binaries` and `.config`:
```yaml
artifacts:
- untracked: true
paths:
- binaries/
+ - .config
```
To disable artifact passing, define the job with empty [dependencies](#dependencies):
@@ -933,11 +925,6 @@ release-job:
- tags
```
-The artifacts will be sent to GitLab after the job finishes successfully and will
-be available for download in the GitLab UI.
-
-[Read more about artifacts.](../../user/project/pipelines/job_artifacts.md)
-
### `artifacts:name`
> Introduced in GitLab 8.6 and GitLab Runner v1.1.0.
@@ -954,26 +941,30 @@ To create an archive with a name of the current job:
job:
artifacts:
name: "$CI_JOB_NAME"
+ paths:
+ - binaries/
```
To create an archive with a name of the current branch or tag including only
-the files that are untracked by Git:
+the binaries directory:
```yaml
job:
artifacts:
name: "$CI_COMMIT_REF_NAME"
- untracked: true
+ paths:
+ - binaries/
```
To create an archive with a name of the current job and the current branch or
-tag including only the files that are untracked by Git:
+tag including only the binaries directory:
```yaml
job:
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
- untracked: true
+ paths:
+ - binaries/
```
To create an archive with a name of the current [stage](#stages) and branch name:
@@ -982,7 +973,8 @@ To create an archive with a name of the current [stage](#stages) and branch name
job:
artifacts:
name: "$CI_JOB_STAGE-$CI_COMMIT_REF_NAME"
- untracked: true
+ paths:
+ - binaries/
```
---
@@ -994,7 +986,8 @@ If you use **Windows Batch** to run your shell scripts you need to replace
job:
artifacts:
name: "%CI_JOB_STAGE%-%CI_COMMIT_REF_NAME%"
- untracked: true
+ paths:
+ - binaries/
```
If you use **Windows PowerShell** to run your shell scripts you need to replace
@@ -1004,7 +997,33 @@ If you use **Windows PowerShell** to run your shell scripts you need to replace
job:
artifacts:
name: "$env:CI_JOB_STAGE-$env:CI_COMMIT_REF_NAME"
- untracked: true
+ paths:
+ - binaries/
+```
+
+### `artifacts:untracked`
+
+`artifacts:untracked` is used to add all Git untracked files as artifacts (along
+to the paths defined in `artifacts:paths`).
+
+NOTE: **Note:**
+To exclude the folders/files which should not be a part of `untracked` just
+add them to `.gitignore`.
+
+Send all Git untracked files:
+
+```yaml
+artifacts:
+ untracked: true
+```
+
+Send all Git untracked files and files in `binaries`:
+
+```yaml
+artifacts:
+ untracked: true
+ paths:
+ - binaries/
```
### `artifacts:when`
diff --git a/doc/development/gitaly.md b/doc/development/gitaly.md
index 26abf967dcf..4f9ca1920a5 100644
--- a/doc/development/gitaly.md
+++ b/doc/development/gitaly.md
@@ -7,6 +7,67 @@ be replaced by Gitaly API calls.
Visit the [Gitaly Migration Board](https://gitlab.com/gitlab-org/gitaly/boards/331341) for current
status of the migration.
+## Developing new Git features
+
+Starting with Gitlab 10.8, all new Git features should be developed in
+Gitaly.
+
+> This is a new process that is not clearly defined yet. If you want
+to contribute a Git feature and you're getting stuck, reach out to the
+Gitaly team or `@jacobvosmaer-gitlab`.
+
+By 'new feature' we mean any method or class in `lib/gitlab/git` that is
+called from outside `lib/gitlab/git`. For new methods that are called
+from inside `lib/gitlab/git`, see 'Modifying existing Git features'
+below.
+
+There should be no new code that touches Git repositories via
+disk access (e.g. Rugged, `git`, `rm -rf`) anywhere outside
+`lib/gitlab/git`.
+
+The process for adding new Gitaly features is:
+
+- exploration / prototyping
+- design and create a new Gitaly RPC [in gitaly-proto](https://gitlab.com/gitlab-org/gitaly-proto)
+- release a new version of gitaly-proto
+- write implementation and tests for the RPC [in Gitaly](https://gitlab.com/gitlab-org/gitaly), in Go or Ruby
+- release a new version of Gitaly
+- write client code in gitlab-ce/ee, gitlab-workhorse or gitlab-shell that calls the new Gitaly RPC
+
+These steps often overlap. It is possible to use an unreleased version
+of Gitaly and gitaly-proto during testing and development.
+
+- See the [Gitaly repo](https://gitlab.com/gitlab-org/gitaly/blob/master/CONTRIBUTING.md#development-and-testing-with-a-custom-gitaly-proto) for instructions on writing server side code with an unreleased protocol.
+- See [below](#running-tests-with-a-locally-modified-version-of-gitaly) for instructions on running gitlab-ce tests with a modified version of Gitaly.
+- In GDK run `gdk install` and restart `gdk run` (or `gdk run app`) to use a locally modified Gitaly version for development
+
+### Gitaly-ruby
+
+It is possible to implement and test RPC's in Gitaly using Ruby code,
+in
+[gitaly-ruby](https://gitlab.com/gitlab-org/gitaly/tree/master/ruby).
+This should make it easier to contribute for developers who are less
+comfortable writing Go code.
+
+There is documentation for this approach in [the Gitaly
+repo](https://gitlab.com/gitlab-org/gitaly/blob/master/doc/ruby_endpoint.md).
+
+## Modifying existing Git features
+
+If you modify existing Git features in `lib/gitlab/git` you need to make
+sure the changes also work in Gitaly. Because we are still in the
+migration process there are a number of subtle pitfalls. Features that
+have been migrated have dual implementations (Gitaly and local). The
+Gitaly implementation may or may not use a vendored (and therefore
+possibly outdated) copy of the local implementation in `lib/gitlab/git`.
+
+To avoid unexpected problems and conflicts, all changes to
+`lib/gitlab/git` need to be approved by a member of the Gitaly team.
+
+For the time being, while the Gitaly migration is still in progress,
+there should be no Enterprise Edition-only Git code in
+`lib/gitlab/git`. Also no mixins.
+
## Feature Flags
Gitaly makes heavy use of [feature flags](feature_flags.md).
@@ -99,10 +160,14 @@ end
## Running tests with a locally modified version of Gitaly
-Normally, gitlab-ce/ee tests use a local clone of Gitaly in `tmp/tests/gitaly`
-pinned at the version specified in GITALY_SERVER_VERSION. If you want
-to run tests locally against a modified version of Gitaly you can
-replace `tmp/tests/gitaly` with a symlink.
+Normally, gitlab-ce/ee tests use a local clone of Gitaly in
+`tmp/tests/gitaly` pinned at the version specified in
+`GITALY_SERVER_VERSION`. The `GITALY_SERVER_VERSION` file supports
+`=my-branch` syntax to use a custom branch in gitlab-org/gitaly. If
+you want to run tests locally against a modified version of Gitaly you
+can replace `tmp/tests/gitaly` with a symlink. This is much faster
+because the `=my-branch` syntax forces a Gitaly re-install each time
+you run `rspec`.
```shell
rm -rf tmp/tests/gitaly
diff --git a/doc/development/i18n/externalization.md b/doc/development/i18n/externalization.md
index 856ef882453..b1bec84a2f3 100644
--- a/doc/development/i18n/externalization.md
+++ b/doc/development/i18n/externalization.md
@@ -131,6 +131,9 @@ There is also and alternative method to [translate messages from validation erro
### Interpolation
+Placeholders in translated text should match the code style of the respective source file.
+For example use `%{created_at}` in Ruby but `%{createdAt}` in JavaScript.
+
- In Ruby/HAML:
```ruby
@@ -141,11 +144,19 @@ There is also and alternative method to [translate messages from validation erro
```js
import { __, sprintf } from '~/locale';
- sprintf(__('Hello %{username}'), { username: 'Joe' }) => 'Hello Joe'
+
+ sprintf(__('Hello %{username}'), { username: 'Joe' }); // => 'Hello Joe'
```
-The placeholders should match the code style of the respective source file.
-For example use `%{created_at}` in Ruby but `%{createdAt}` in JavaScript.
+ By default, `sprintf` escapes the placeholder values.
+ If you want to take care of that yourself, you can pass `false` as third argument.
+
+ ```js
+ import { __, sprintf } from '~/locale';
+
+ sprintf(__('This is %{value}'), { value: '<strong>bold</strong>' }); // => 'This is &lt;strong&gt;bold&lt;/strong&gt;'
+ sprintf(__('This is %{value}'), { value: '<strong>bold</strong>' }, false); // => 'This is <strong>bold</strong>'
+ ```
### Plurals
diff --git a/doc/development/new_fe_guide/development/components.md b/doc/development/new_fe_guide/development/components.md
index 637099d1e83..899efb398cd 100644
--- a/doc/development/new_fe_guide/development/components.md
+++ b/doc/development/new_fe_guide/development/components.md
@@ -1,3 +1,21 @@
# Components
-> TODO: Add content
+## Graphs
+
+We have a lot of graphing libraries in our codebase to render graphs. In an effort to improve maintainability, new graphs should use [D3.js](https://d3js.org/). If a new graph is fairly simple, consider implementing it in SVGs or HTML5 canvas.
+
+We chose D3 as our library going forward because of the following features:
+
+* [Tree shaking webpack capabilities.](https://github.com/d3/d3/blob/master/CHANGES.md#changes-in-d3-40)
+* [Compatible with vue.js as well as vanilla javascript.](https://github.com/d3/d3/blob/master/CHANGES.md#changes-in-d3-40)
+
+D3 is very popular across many projects outside of GitLab:
+
+* [The New York Times](https://archive.nytimes.com/www.nytimes.com/interactive/2012/02/13/us/politics/2013-budget-proposal-graphic.html)
+* [plot.ly](https://plot.ly/)
+* [Droptask](https://www.droptask.com/)
+
+Within GitLab, D3 has been used for the following notable features
+
+* [Prometheus graphs](https://docs.gitlab.com/ee/user/project/integrations/prometheus.html)
+* Contribution calendars
diff --git a/doc/development/testing_guide/frontend_testing.md b/doc/development/testing_guide/frontend_testing.md
index 0c63f51cb45..0a6f402d5d2 100644
--- a/doc/development/testing_guide/frontend_testing.md
+++ b/doc/development/testing_guide/frontend_testing.md
@@ -152,19 +152,33 @@ is sufficient (and saves you some time).
### Live testing and focused testing
While developing locally, it may be helpful to keep karma running so that you
-can get instant feedback on as you write tests and modify code. To do this
-you can start karma with `npm run karma-start`. It will compile the javascript
+can get instant feedback on as you write tests and modify code. To do this
+you can start karma with `yarn run karma-start`. It will compile the javascript
assets and run a server at `http://localhost:9876/` where it will automatically
-run the tests on any browser which connects to it. You can enter that url on
+run the tests on any browser which connects to it. You can enter that url on
multiple browsers at once to have it run the tests on each in parallel.
While karma is running, any changes you make will instantly trigger a recompile
and retest of the entire test suite, so you can see instantly if you've broken
-a test with your changes. You can use [jasmine focused][jasmine-focus] or
+a test with your changes. You can use [jasmine focused][jasmine-focus] or
excluded tests (with `fdescribe` or `xdescribe`) to get karma to run only the
tests you want while you're working on a specific feature, but make sure to
remove these directives when you commit your code.
+It is also possible to only run karma on specific folders or files by filtering
+the run tests via the argument `--filter-spec` or short `-f`:
+
+```bash
+# Run all files
+yarn karma-start
+# Run specific spec files
+yarn karma-start --filter-spec profile/account/components/update_username_spec.js
+# Run specific spec folder
+yarn karma-start --filter-spec profile/account/components/
+# Run all specs which path contain vue_shared or vie
+yarn karma-start -f vue_shared -f vue_mr_widget
+```
+
## RSpec feature integration tests
Information on setting up and running RSpec integration tests with
@@ -176,7 +190,7 @@ Information on setting up and running RSpec integration tests with
Similar errors will be thrown if you're using JavaScript features not yet
supported by the PhantomJS test runner which is used for both Karma and RSpec
-tests. We polyfill some JavaScript objects for older browsers, but some
+tests. We polyfill some JavaScript objects for older browsers, but some
features are still unavailable:
- Array.from
@@ -188,7 +202,7 @@ features are still unavailable:
- Symbol/Symbol.iterator
- Spread
-Until these are polyfilled appropriately, they should not be used. Please
+Until these are polyfilled appropriately, they should not be used. Please
update this list with additional unsupported features.
### RSpec errors due to JavaScript
@@ -223,7 +237,7 @@ end
### Spinach errors due to missing JavaScript
NOTE: **Note:** Since we are discouraging the use of Spinach when writing new
-feature tests, you shouldn't ever need to use this. This information is kept
+feature tests, you shouldn't ever need to use this. This information is kept
available for legacy purposes only.
In Spinach, the JavaScript driver is enabled differently. In the `*.feature`
diff --git a/doc/install/installation.md b/doc/install/installation.md
index 3cf6f7b7ddf..85174b64ff7 100644
--- a/doc/install/installation.md
+++ b/doc/install/installation.md
@@ -301,7 +301,7 @@ sudo usermod -aG redis git
### Clone the Source
# Clone GitLab repository
- sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 10-6-stable gitlab
+ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 10-7-stable gitlab
**Note:** You can change `10-6-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server!
diff --git a/doc/topics/autodevops/index.md b/doc/topics/autodevops/index.md
index e88b787187c..89b8ea209b3 100644
--- a/doc/topics/autodevops/index.md
+++ b/doc/topics/autodevops/index.md
@@ -455,17 +455,19 @@ The following variables can be used for setting up the Auto DevOps domain,
providing a custom Helm chart, or scaling your application. PostgreSQL can be
also be customized, and you can easily use a [custom buildpack](#custom-buildpacks).
-| **Variable** | **Description** |
-| ------------ | --------------- |
-| `AUTO_DEVOPS_DOMAIN` | The [Auto DevOps domain](#auto-devops-domain); by default set automatically by the [Auto DevOps setting](#enabling-auto-devops). |
-| `AUTO_DEVOPS_CHART` | The Helm Chart used to deploy your apps; defaults to the one [provided by GitLab](https://gitlab.com/charts/charts.gitlab.io/tree/master/charts/auto-deploy-app). |
-| `PRODUCTION_REPLICAS` | The number of replicas to deploy in the production environment; defaults to 1. |
-| `CANARY_PRODUCTION_REPLICAS`| The number of canary replicas to deploy for [Canary Deployments](https://docs.gitlab.com/ee/user/project/canary_deployments.html) in the production environment. |
-| `POSTGRES_ENABLED` | Whether PostgreSQL is enabled; defaults to `"true"`. Set to `false` to disable the automatic deployment of PostgreSQL. |
-| `POSTGRES_USER` | The PostgreSQL user; defaults to `user`. Set it to use a custom username. |
-| `POSTGRES_PASSWORD` | The PostgreSQL password; defaults to `testing-password`. Set it to use a custom password. |
-| `POSTGRES_DB` | The PostgreSQL database name; defaults to the value of [`$CI_ENVIRONMENT_SLUG`](../../ci/variables/README.md#predefined-variables-environment-variables). Set it to use a custom database name. |
-| `BUILDPACK_URL` | The buildpack's full URL. It can point to either Git repositories or a tarball URL. For Git repositories, it is possible to point to a specific `ref`, for example `https://github.com/heroku/heroku-buildpack-ruby.git#v142`|
+| **Variable** | **Description** |
+| ------------ | --------------- |
+| `AUTO_DEVOPS_DOMAIN` | The [Auto DevOps domain](#auto-devops-domain); by default set automatically by the [Auto DevOps setting](#enabling-auto-devops). |
+| `AUTO_DEVOPS_CHART` | The Helm Chart used to deploy your apps; defaults to the one [provided by GitLab](https://gitlab.com/charts/charts.gitlab.io/tree/master/charts/auto-deploy-app). |
+| `REPLICAS` | The number of replicas to deploy; defaults to 1. |
+| `PRODUCTION_REPLICAS` | The number of replicas to deploy in the production environment. This takes precedence over `REPLICAS`; defaults to 1. |
+| `CANARY_REPLICAS` | The number of canary replicas to deploy for [Canary Deployments](https://docs.gitlab.com/ee/user/project/canary_deployments.html); defaults to 1 |
+| `CANARY_PRODUCTION_REPLICAS` | The number of canary replicas to deploy for [Canary Deployments](https://docs.gitlab.com/ee/user/project/canary_deployments.html) in the production environment. This takes precedence over `CANARY_REPLICAS`; defaults to 1 |
+| `POSTGRES_ENABLED` | Whether PostgreSQL is enabled; defaults to `"true"`. Set to `false` to disable the automatic deployment of PostgreSQL. |
+| `POSTGRES_USER` | The PostgreSQL user; defaults to `user`. Set it to use a custom username. |
+| `POSTGRES_PASSWORD` | The PostgreSQL password; defaults to `testing-password`. Set it to use a custom password. |
+| `POSTGRES_DB` | The PostgreSQL database name; defaults to the value of [`$CI_ENVIRONMENT_SLUG`](../../ci/variables/README.md#predefined-variables-environment-variables). Set it to use a custom database name. |
+| `BUILDPACK_URL` | The buildpack's full URL. It can point to either Git repositories or a tarball URL. For Git repositories, it is possible to point to a specific `ref`, for example `https://github.com/heroku/heroku-buildpack-ruby.git#v142` |
TIP: **Tip:**
Set up the replica variables using a
@@ -496,8 +498,9 @@ The general rule is: `TRACK_ENV_REPLICAS`. Where:
That way, you can define your own `TRACK_ENV_REPLICAS` variables with which
you will be able to scale the pod's replicas easily.
-In the example below, the environment's name is `qa` which would result in
-looking for the `QA_REPLICAS` environment variable:
+In the example below, the environment's name is `qa` and it deploys the track
+`foo` which would result in looking for the `FOO_QA_REPLICAS` environment
+variable:
```yaml
QA testing:
@@ -505,11 +508,11 @@ QA testing:
environment:
name: qa
script:
- - deploy qa
+ - deploy foo
```
-If, in addition, there was also a `track: foo` defined in the application's Helm
-chart, like:
+The track `foo` being referenced would also need to be defined in the
+application's Helm chart, like:
```yaml
replicaCount: 1
@@ -531,8 +534,6 @@ service:
internalPort: 5000
```
-then the environment variable would be `FOO_QA_REPLICAS`.
-
## Currently supported languages
NOTE: **Note:**
diff --git a/doc/update/10.6-to-10.7.md b/doc/update/10.6-to-10.7.md
new file mode 100644
index 00000000000..4a76ae14d2e
--- /dev/null
+++ b/doc/update/10.6-to-10.7.md
@@ -0,0 +1,361 @@
+---
+comments: false
+---
+
+# From 10.6 to 10.7
+
+Make sure you view this update guide from the tag (version) of GitLab you would
+like to install. In most cases this should be the highest numbered production
+tag (without rc in it). You can select the tag in the version dropdown at the
+top left corner of GitLab (below the menu bar).
+
+If the highest number stable branch is unclear please check the
+[GitLab Blog](https://about.gitlab.com/blog/archives.html) for installation
+guide links by version.
+
+### 1. Stop server
+
+```bash
+sudo service gitlab stop
+```
+
+### 2. Backup
+
+NOTE: If you installed GitLab from source, make sure `rsync` is installed.
+
+```bash
+cd /home/git/gitlab
+
+sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
+```
+
+### 3. Update Ruby
+
+NOTE: GitLab 9.0 and higher only support Ruby 2.3.x and dropped support for Ruby 2.1.x. Be
+sure to upgrade your interpreter if necessary.
+
+You can check which version you are running with `ruby -v`.
+
+Download and compile Ruby:
+
+```bash
+mkdir /tmp/ruby && cd /tmp/ruby
+curl --remote-name --progress https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.6.tar.gz
+echo '4e6a0f828819e15d274ae58485585fc8b7caace0 ruby-2.3.6.tar.gz' | shasum -c - && tar xzf ruby-2.3.6.tar.gz
+cd ruby-2.3.6
+./configure --disable-install-rdoc
+make
+sudo make install
+```
+
+Install Bundler:
+
+```bash
+sudo gem install bundler --no-ri --no-rdoc
+```
+
+### 4. Update Node
+
+GitLab utilizes [webpack](http://webpack.js.org) to compile frontend assets.
+This requires a minimum version of node v6.0.0.
+
+You can check which version you are running with `node -v`. If you are running
+a version older than `v6.0.0` you will need to update to a newer version. You
+can find instructions to install from community maintained packages or compile
+from source at the nodejs.org website.
+
+<https://nodejs.org/en/download/>
+
+GitLab also requires the use of yarn `>= v1.2.0` to manage JavaScript
+dependencies.
+
+```bash
+curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
+echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
+sudo apt-get update
+sudo apt-get install yarn
+```
+
+More information can be found on the [yarn website](https://yarnpkg.com/en/docs/install).
+
+### 5. Update Go
+
+NOTE: GitLab 9.2 and higher only supports Go 1.8.3 and dropped support for Go
+1.5.x through 1.7.x. Be sure to upgrade your installation if necessary.
+
+You can check which version you are running with `go version`.
+
+Download and install Go:
+
+```bash
+# Remove former Go installation folder
+sudo rm -rf /usr/local/go
+
+curl --remote-name --progress https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
+echo '1862f4c3d3907e59b04a757cfda0ea7aa9ef39274af99a784f5be843c80c6772 go1.8.3.linux-amd64.tar.gz' | shasum -a256 -c - && \
+ sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
+sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/
+rm go1.8.3.linux-amd64.tar.gz
+```
+
+### 6. Get latest code
+
+```bash
+cd /home/git/gitlab
+
+sudo -u git -H git fetch --all --prune
+sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically
+sudo -u git -H git checkout -- locale
+```
+
+For GitLab Community Edition:
+
+```bash
+cd /home/git/gitlab
+
+sudo -u git -H git checkout 10-7-stable
+```
+
+OR
+
+For GitLab Enterprise Edition:
+
+```bash
+cd /home/git/gitlab
+
+sudo -u git -H git checkout 10-7-stable-ee
+```
+
+### 7. Update gitlab-shell
+
+```bash
+cd /home/git/gitlab-shell
+
+sudo -u git -H git fetch --all --tags --prune
+sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_SHELL_VERSION)
+sudo -u git -H bin/compile
+```
+
+### 8. Update gitlab-workhorse
+
+Install and compile gitlab-workhorse. GitLab-Workhorse uses
+[GNU Make](https://www.gnu.org/software/make/).
+If you are not using Linux you may have to run `gmake` instead of
+`make` below.
+
+```bash
+cd /home/git/gitlab-workhorse
+
+sudo -u git -H git fetch --all --tags --prune
+sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_WORKHORSE_VERSION)
+sudo -u git -H make
+```
+
+### 9. Update Gitaly
+
+#### New Gitaly configuration options required
+
+In order to function Gitaly needs some additional configuration information. Below we assume you installed Gitaly in `/home/git/gitaly` and GitLab Shell in `/home/git/gitlab-shell`.
+
+```shell
+echo '
+[gitaly-ruby]
+dir = "/home/git/gitaly/ruby"
+
+[gitlab-shell]
+dir = "/home/git/gitlab-shell"
+' | sudo -u git tee -a /home/git/gitaly/config.toml
+```
+
+#### Check Gitaly configuration
+
+Due to a bug in the `rake gitlab:gitaly:install` script your Gitaly
+configuration file may contain syntax errors. The block name
+`[[storages]]`, which may occur more than once in your `config.toml`
+file, should be `[[storage]]` instead.
+
+```shell
+sudo -u git -H sed -i.pre-10.1 's/\[\[storages\]\]/[[storage]]/' /home/git/gitaly/config.toml
+```
+
+#### Compile Gitaly
+
+```shell
+cd /home/git/gitaly
+sudo -u git -H git fetch --all --tags --prune
+sudo -u git -H git checkout v$(</home/git/gitlab/GITALY_SERVER_VERSION)
+sudo -u git -H make
+```
+
+### 10. Update MySQL permissions
+
+If you are using MySQL you need to grant the GitLab user the necessary
+permissions on the database:
+
+```bash
+mysql -u root -p -e "GRANT TRIGGER ON \`gitlabhq_production\`.* TO 'git'@'localhost';"
+```
+
+If you use MySQL with replication, or just have MySQL configured with binary logging,
+you will need to also run the following on all of your MySQL servers:
+
+```bash
+mysql -u root -p -e "SET GLOBAL log_bin_trust_function_creators = 1;"
+```
+
+You can make this setting permanent by adding it to your `my.cnf`:
+
+```
+log_bin_trust_function_creators=1
+```
+
+### 11. Update configuration files
+
+#### New configuration options for `gitlab.yml`
+
+There might be configuration options available for [`gitlab.yml`][yaml]. View them with the command below and apply them manually to your current `gitlab.yml`:
+
+```sh
+cd /home/git/gitlab
+
+git diff origin/10-6-stable:config/gitlab.yml.example origin/10-7-stable:config/gitlab.yml.example
+```
+
+#### Nginx configuration
+
+Ensure you're still up-to-date with the latest NGINX configuration changes:
+
+```sh
+cd /home/git/gitlab
+
+# For HTTPS configurations
+git diff origin/10-6-stable:lib/support/nginx/gitlab-ssl origin/10-7-stable:lib/support/nginx/gitlab-ssl
+
+# For HTTP configurations
+git diff origin/10-6-stable:lib/support/nginx/gitlab origin/10-7-stable:lib/support/nginx/gitlab
+```
+
+If you are using Strict-Transport-Security in your installation to continue using it you must enable it in your Nginx
+configuration as GitLab application no longer handles setting it.
+
+If you are using Apache instead of NGINX please see the updated [Apache templates].
+Also note that because Apache does not support upstreams behind Unix sockets you
+will need to let gitlab-workhorse listen on a TCP port. You can do this
+via [/etc/default/gitlab].
+
+[Apache templates]: https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache
+[/etc/default/gitlab]: https://gitlab.com/gitlab-org/gitlab-ce/blob/10-7-stable/lib/support/init.d/gitlab.default.example#L38
+
+#### SMTP configuration
+
+If you're installing from source and use SMTP to deliver mail, you will need to add the following line
+to config/initializers/smtp_settings.rb:
+
+```ruby
+ActionMailer::Base.delivery_method = :smtp
+```
+
+See [smtp_settings.rb.sample] as an example.
+
+[smtp_settings.rb.sample]: https://gitlab.com/gitlab-org/gitlab-ce/blob/10-7-stable/config/initializers/smtp_settings.rb.sample#L13
+
+#### Init script
+
+There might be new configuration options available for [`gitlab.default.example`][gl-example]. View them with the command below and apply them manually to your current `/etc/default/gitlab`:
+
+```sh
+cd /home/git/gitlab
+
+git diff origin/10-6-stable:lib/support/init.d/gitlab.default.example origin/10-7-stable:lib/support/init.d/gitlab.default.example
+```
+
+Ensure you're still up-to-date with the latest init script changes:
+
+```bash
+cd /home/git/gitlab
+
+sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
+```
+
+For Ubuntu 16.04.1 LTS:
+
+```bash
+sudo systemctl daemon-reload
+```
+
+### 12. Install libs, migrations, etc.
+
+```bash
+cd /home/git/gitlab
+
+# MySQL installations (note: the line below states '--without postgres')
+sudo -u git -H bundle install --without postgres development test --deployment
+
+# PostgreSQL installations (note: the line below states '--without mysql')
+sudo -u git -H bundle install --without mysql development test --deployment
+
+# Optional: clean up old gems
+sudo -u git -H bundle clean
+
+# Run database migrations
+sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
+
+# Compile GetText PO files
+
+sudo -u git -H bundle exec rake gettext:compile RAILS_ENV=production
+
+# Update node dependencies and recompile assets
+sudo -u git -H bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
+
+# Clean up cache
+sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production
+```
+
+**MySQL installations**: Run through the `MySQL strings limits` and `Tables and data conversion to utf8mb4` [tasks](../install/database_mysql.md).
+
+### 13. Start application
+
+```bash
+sudo service gitlab start
+sudo service nginx restart
+```
+
+### 14. Check application status
+
+Check if GitLab and its environment are configured correctly:
+
+```bash
+cd /home/git/gitlab
+
+sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
+```
+
+To make sure you didn't miss anything run a more thorough check:
+
+```bash
+cd /home/git/gitlab
+
+sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
+```
+
+If all items are green, then congratulations, the upgrade is complete!
+
+## Things went south? Revert to previous version (10.5)
+
+### 1. Revert the code to the previous version
+
+Follow the [upgrade guide from 10.5 to 10.6](10.5-to-10.6.md), except for the
+database migration (the backup is already migrated to the previous version).
+
+### 2. Restore from the backup
+
+```bash
+cd /home/git/gitlab
+
+sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
+```
+
+If you have more than one backup `*.tar` file(s) please add `BACKUP=timestamp_of_backup` to the command above.
+
+[yaml]: https://gitlab.com/gitlab-org/gitlab-ce/blob/10-7-stable/config/gitlab.yml.example
+[gl-example]: https://gitlab.com/gitlab-org/gitlab-ce/blob/10-7-stable/lib/support/init.d/gitlab.default.example
diff --git a/doc/user/discussions/index.md b/doc/user/discussions/index.md
index eacfe2baa27..159109e8954 100644
--- a/doc/user/discussions/index.md
+++ b/doc/user/discussions/index.md
@@ -14,6 +14,10 @@ The comment area supports [Markdown] and [quick actions]. One can edit their
own comment at any time, and anyone with [Master access level][permissions] or
higher can also edit a comment made by someone else.
+You could also reply to the notification email in order to reply to a comment,
+provided that [Reply by email] is configured by your GitLab admin. This also
+supports [Markdown] and [quick actions] as if replied from the web.
+
Apart from the standard comments, you also have the option to create a comment
in the form of a resolvable or threaded discussion.
@@ -283,3 +287,4 @@ edit existing comments. Non-team members are restricted from adding or editing c
[markdown]: ../markdown.md
[quick actions]: ../project/quick_actions.md
[permissions]: ../permissions.md
+[Reply by email]: ../../administration/reply_by_email.md
diff --git a/doc/user/project/integrations/prometheus_library/cloudwatch.md b/doc/user/project/integrations/prometheus_library/cloudwatch.md
index 34a0b97a171..bf6c0dc0e7e 100644
--- a/doc/user/project/integrations/prometheus_library/cloudwatch.md
+++ b/doc/user/project/integrations/prometheus_library/cloudwatch.md
@@ -6,7 +6,7 @@ GitLab has support for automatically detecting and monitoring AWS resources, sta
## Requirements
-The [Prometheus service](../prometheus/index.md) must be enabled.
+The [Prometheus service](../prometheus.md) must be enabled.
## Metrics supported
diff --git a/doc/user/project/integrations/prometheus_library/haproxy.md b/doc/user/project/integrations/prometheus_library/haproxy.md
index 518018e5839..cd398f7c0fd 100644
--- a/doc/user/project/integrations/prometheus_library/haproxy.md
+++ b/doc/user/project/integrations/prometheus_library/haproxy.md
@@ -5,7 +5,7 @@ GitLab has support for automatically detecting and monitoring HAProxy. This is p
## Requirements
-The [Prometheus service](../prometheus/index.md) must be enabled.
+The [Prometheus service](../prometheus.md) must be enabled.
## Metrics supported
diff --git a/doc/user/project/integrations/prometheus_library/metrics.md b/doc/user/project/integrations/prometheus_library/metrics.md
index f09ecf9ff2d..96a22316265 100644
--- a/doc/user/project/integrations/prometheus_library/metrics.md
+++ b/doc/user/project/integrations/prometheus_library/metrics.md
@@ -1,4 +1,5 @@
# Prometheus Metrics library
+
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8935) in GitLab 9.0
GitLab offers automatic detection of select [Prometheus exporters](https://prometheus.io/docs/instrumenting/exporters/). Currently supported exporters are:
@@ -15,7 +16,7 @@ We have tried to surface the most important metrics for each exporter, and will
GitLab retrieves performance data from the configured Prometheus server, and attempts to identifying the presence of known metrics. Once identified, GitLab then needs to be able to map the data to a particular environment.
In order to isolate and only display relevant metrics for a given environment, GitLab needs a method to detect which labels are associated. To do that,
-GitLab uses the defined queries and fills in the environment specific variables. Typically this involves looking for the [$CI_ENVIRONMENT_SLUG](https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables), but may also include other information such as the project's Kubernetes namespace. Each search query is defined in the [exporter specific documentation](#prometheus-metrics-library).
+GitLab uses the defined queries and fills in the environment specific variables. Typically this involves looking for the [$CI_ENVIRONMENT_SLUG](../../../../ci/variables/README.md#predefined-variables-environment-variables), but may also include other information such as the project's Kubernetes namespace. Each search query is defined in the [exporter specific documentation](#prometheus-metrics-library).
## Adding to the library
diff --git a/doc/user/project/integrations/prometheus_library/nginx.md b/doc/user/project/integrations/prometheus_library/nginx.md
index 7fb8369d3c1..fea3231006b 100644
--- a/doc/user/project/integrations/prometheus_library/nginx.md
+++ b/doc/user/project/integrations/prometheus_library/nginx.md
@@ -6,7 +6,7 @@ GitLab has support for automatically detecting and monitoring NGINX. This is pro
## Requirements
-The [Prometheus service](../prometheus/index.md) must be enabled.
+The [Prometheus service](../prometheus.md) must be enabled.
## Metrics supported
diff --git a/doc/user/project/integrations/prometheus_library/nginx_ingress.md b/doc/user/project/integrations/prometheus_library/nginx_ingress.md
index 49b34c82ae6..590b1c4275a 100644
--- a/doc/user/project/integrations/prometheus_library/nginx_ingress.md
+++ b/doc/user/project/integrations/prometheus_library/nginx_ingress.md
@@ -6,7 +6,7 @@ GitLab has support for automatically detecting and monitoring the Kubernetes NGI
## Requirements
-[Prometheus integration](../prometheus/index.md) must be active.
+[Prometheus integration](../prometheus.md) must be active.
## Metrics supported
@@ -27,7 +27,7 @@ For other deployments, there is [some configuration](#manually-setting-up-nginx-
### About managed NGINX Ingress deployments
-NGINX Ingress is deployed into the `gitlab-managed-apps` namespace, using the [official Helm chart](https://github.com/kubernetes/charts/tree/master/stable/nginx-ingress). NGINX Ingress will be [externally reachable via the Load Balancer's IP](https://docs.gitlab.com/ce/user/project/clusters/index.html#getting-the-external-ip-address).
+NGINX Ingress is deployed into the `gitlab-managed-apps` namespace, using the [official Helm chart](https://github.com/kubernetes/charts/tree/master/stable/nginx-ingress). NGINX Ingress will be [externally reachable via the Load Balancer's IP](../../clusters/index.md#getting-the-external-ip-address).
NGINX is configured for Prometheus monitoring, by setting:
* `enable-vts-status: "true"`, to export Prometheus metrics
@@ -51,4 +51,4 @@ Managing these settings depends on how NGINX ingress has been deployed. If you h
In order to isolate and only display relevant metrics for a given environment, GitLab needs a method to detect which labels are associated. To do this, GitLab will search for metrics with appropriate labels. In this case, the `upstream` label must be of the form `<KUBE_NAMESPACE>-<CI_ENVIRONMENT_SLUG>-*`.
-If you have used [Auto Deploy](https://docs.gitlab.com/ee/ci/autodeploy/index.html) to deploy your app, this format will be used automatically and metrics will be detected with no action on your part.
+If you have used [Auto Deploy](../../../../topics/autodevops/index.md#auto-deploy) to deploy your app, this format will be used automatically and metrics will be detected with no action on your part.
diff --git a/doc/user/project/settings/index.md b/doc/user/project/settings/index.md
index 888dd0e143a..a387c1e443e 100644
--- a/doc/user/project/settings/index.md
+++ b/doc/user/project/settings/index.md
@@ -57,15 +57,20 @@ Here you can run housekeeping, archive, rename, transfer, or remove a project.
NOTE: **Note:**
Only project Owners and Admin users have the [permissions] to archive a project.
-An archived project will be hidden by default in the project listings.
+Archiving a project makes it read-only for all users and indicates that it is
+no longer actively maintained. Projects that have been archived can also be
+unarchived.
+
+When a project is archived, the repository, issues, merge requests and all
+other features are read-only. Archived projects are also hidden
+in project listings.
+
+To archive a project:
1. Navigate to your project's **Settings > General > Advanced settings**.
-1. Under "Archive project", hit the **Archive project** button.
+1. In the Archive project section, click the **Archive project** button.
1. Confirm the action when asked to.
-An archived project can be fully restored and will therefore retain its
-repository and all associated resources whilst in an archived state.
-
#### Renaming a repository
NOTE: **Note:**
diff --git a/features/project/commits/branches.feature b/features/project/commits/branches.feature
deleted file mode 100644
index c57376aecff..00000000000
--- a/features/project/commits/branches.feature
+++ /dev/null
@@ -1,42 +0,0 @@
-@project_commits
-Feature: Project Commits Branches
- Background:
- Given I sign in as a user
- And I own project "Shop"
- And project "Shop" has protected branches
-
- Scenario: I can see project all git branches
- Given I visit project branches page
- Then I should see "Shop" all branches list
-
- Scenario: I can see project protected git branches
- Given I visit project protected branches page
- Then I should see "Shop" protected branches list
-
- @javascript
- Scenario: I create a branch
- Given I visit project branches page
- And I click new branch link
- And I submit new branch form
- Then I should see new branch created
-
- @javascript
- Scenario: I delete a branch
- Given I visit project branches page
- And I filter for branch improve/awesome
- And I click branch 'improve/awesome' delete link
- Then I should not see branch 'improve/awesome'
-
- @javascript
- Scenario: I create a branch with invalid name
- Given I visit project branches page
- And I click new branch link
- And I submit new branch form with invalid name
- Then I should see new an error that branch is invalid
-
- @javascript
- Scenario: I create a branch that already exists
- Given I visit project branches page
- And I click new branch link
- And I submit new branch form with branch that already exists
- Then I should see new an error that branch already exists
diff --git a/features/project/issues/milestones.feature b/features/project/issues/milestones.feature
deleted file mode 100644
index 77c8ed6e5bf..00000000000
--- a/features/project/issues/milestones.feature
+++ /dev/null
@@ -1,43 +0,0 @@
-@project_issues
-Feature: Project Issues Milestones
- Background:
- Given I sign in as a user
- And I own project "Shop"
- And project "Shop" has milestone "v2.2"
- Given I visit project "Shop" milestones page
-
- Scenario: I should see active milestones
- Then I should see milestone "v2.2"
-
- Scenario: I should see milestone
- Given I click link "v2.2"
- Then I should see milestone "v2.2"
-
- @javascript
- Scenario: I create and delete new milestone
- Given I click link "New Milestone"
- And I submit new milestone "v2.3"
- Then I should see milestone "v2.3"
- Given I click button to remove milestone
- And I confirm in modal
- When I visit project "Shop" activity page
- Then I should see deleted milestone activity
-
- @javascript
- Scenario: I delete new milestone
- Given I click button to remove milestone
- And I confirm in modal
- And I should see no milestones
-
- @javascript
- Scenario: Listing closed issues
- Given the milestone has open and closed issues
- And I click link "v2.2"
- Then I should see 3 issues
-
- # Markdown
-
- Scenario: Headers inside the description should have ids generated for them.
- Given I click link "v2.2"
- # PLEASE USE the `have_header_with_correct_id_and_link(level, text, id, parent)` matcher on migrating this spec to rspec.
- Then Header "Description header" should have correct id and link
diff --git a/features/project/project.feature b/features/project/project.feature
deleted file mode 100644
index 23817ef3ac9..00000000000
--- a/features/project/project.feature
+++ /dev/null
@@ -1,86 +0,0 @@
-Feature: Project
- Background:
- Given I sign in as a user
- And I own project "Shop"
- And project "Shop" has push event
- And I visit project "Shop" page
-
- Scenario: I edit the project avatar
- Given I visit edit project "Shop" page
- When I change the project avatar
- And I should see new project avatar
- And I should see the "Remove avatar" button
-
- Scenario: I remove the project avatar
- Given I visit edit project "Shop" page
- And I have an project avatar
- When I remove my project avatar
- Then I should see the default project avatar
- And I should not see the "Remove avatar" button
-
- @javascript
- Scenario: I should have readme on page
- And I visit project "Shop" page
- Then I should see project "Shop" README
-
- Scenario: I should see last commit with CI
- Given project "Shop" has CI enabled
- Given project "Shop" has CI build
- And I visit project "Shop" page
- And I should see last commit with CI status
-
- @javascript
- Scenario: I should see project activity
- When I visit project "Shop" activity page
- Then I should see project "Shop" activity feed
-
- Scenario: I visit edit project
- When I visit edit project "Shop" page
- Then I should see project settings
-
- Scenario: I edit project
- When I visit edit project "Shop" page
- And change project settings
- And I save project
- Then I should see project with new settings
-
- Scenario: I change project path
- When I visit edit project "Shop" page
- And change project path settings
- Then I should see project with new path settings
-
- Scenario: I should change project default branch
- When I visit edit project "Shop" page
- And change project default branch
- And I save project
- Then I should see project default branch changed
-
- Scenario: I tag a project
- When I visit edit project "Shop" page
- Then I should see project settings
- And I add project tags
- And I save project
- Then I should see project tags
-
- Scenario: I should not see "New Issue" or "New Merge Request" buttons
- Given I disable issues and merge requests in project
- When I visit project "Shop" page
- Then I should not see "New Issue" button
- And I should not see "New Merge Request" button
-
- Scenario: I should not see Project snippets
- Given I disable snippets in project
- When I visit project "Shop" page
- Then I should not see "Snippets" button
-
- @javascript
- Scenario: I edit Project Notifications
- Given I click notifications drop down button
- When I choose Mention setting
- Then I should see Notification saved message
-
- Scenario: I should see command line instructions
- Given I own an empty project
- And I visit my empty project page
- And I create bare repo
- Then I should see command line instructions
diff --git a/features/steps/project/commits/branches.rb b/features/steps/project/commits/branches.rb
index c3ae33d2aa9..3ecd4c8b672 100644
--- a/features/steps/project/commits/branches.rb
+++ b/features/steps/project/commits/branches.rb
@@ -7,37 +7,14 @@ class Spinach::Features::ProjectCommitsBranches < Spinach::FeatureSteps
click_link "All"
end
- step 'I should see "Shop" all branches list' do
- expect(page).to have_content "Branches"
- expect(page).to have_content "master"
- end
-
step 'I click link "Protected"' do
click_link "Protected"
end
- step 'I should see "Shop" protected branches list' do
- page.within ".protected-branches-list" do
- expect(page).to have_content "stable"
- expect(page).not_to have_content "master"
- end
- end
-
- step 'project "Shop" has protected branches' do
- project = Project.find_by(name: "Shop")
- create(:protected_branch, project: project, name: "stable")
- end
-
step 'I click new branch link' do
click_link "New branch"
end
- step 'I submit new branch form' do
- fill_in 'branch_name', with: 'deploy_keys'
- select_branch('master')
- click_button 'Create branch'
- end
-
step 'I submit new branch form with invalid name' do
fill_in 'branch_name', with: '1.0 stable'
page.find("body").click # defocus the branch_name input
@@ -45,40 +22,6 @@ class Spinach::Features::ProjectCommitsBranches < Spinach::FeatureSteps
click_button 'Create branch'
end
- step 'I submit new branch form with branch that already exists' do
- fill_in 'branch_name', with: 'master'
- select_branch('master')
- click_button 'Create branch'
- end
-
- step 'I should see new branch created' do
- expect(page).to have_content 'deploy_keys'
- end
-
- step 'I should see new an error that branch is invalid' do
- expect(page).to have_content 'Branch name is invalid'
- expect(page).to have_content "can't contain spaces"
- end
-
- step 'I should see new an error that branch already exists' do
- expect(page).to have_content 'Branch already exists'
- end
-
- step 'I filter for branch improve/awesome' do
- fill_in 'branch-search', with: 'improve/awesome'
- find('#branch-search').native.send_keys(:enter)
- end
-
- step "I click branch 'improve/awesome' delete link" do
- page.within '.js-branch-improve\/awesome' do
- accept_alert { find('.btn-remove').click }
- end
- end
-
- step "I should not see branch 'improve/awesome'" do
- expect(page).to have_css('.js-branch-improve\\/awesome', visible: :hidden)
- end
-
def select_branch(branch_name)
find('.git-revision-dropdown-toggle').click
diff --git a/features/steps/project/issues/milestones.rb b/features/steps/project/issues/milestones.rb
index 4ce67aa651c..30927306a4f 100644
--- a/features/steps/project/issues/milestones.rb
+++ b/features/steps/project/issues/milestones.rb
@@ -4,35 +4,6 @@ class Spinach::Features::ProjectIssuesMilestones < Spinach::FeatureSteps
include SharedPaths
include SharedMarkdown
- step 'I should see milestone "v2.2"' do
- milestone = @project.milestones.find_by(title: "v2.2")
- expect(page).to have_content(milestone.title[0..10])
- expect(page).to have_content(milestone.expires_at)
- expect(page).to have_content("Issues")
- end
-
- step 'I click link "v2.2"' do
- click_link "v2.2"
- end
-
- step 'I click link "New Milestone"' do
- page.within('.nav-controls') do
- click_link "New milestone"
- end
- end
-
- step 'I submit new milestone "v2.3"' do
- fill_in "milestone_title", with: "v2.3"
- click_button "Create milestone"
- end
-
- step 'I should see milestone "v2.3"' do
- milestone = @project.milestones.find_by(title: "v2.3")
- expect(page).to have_content(milestone.title[0..10])
- expect(page).to have_content(milestone.expires_at)
- expect(page).to have_content("Issues")
- end
-
step 'project "Shop" has milestone "v2.2"' do
project = Project.find_by(name: "Shop")
milestone = create(:milestone,
@@ -43,36 +14,7 @@ class Spinach::Features::ProjectIssuesMilestones < Spinach::FeatureSteps
3.times { create(:issue, project: project, milestone: milestone) }
end
- step 'the milestone has open and closed issues' do
- project = Project.find_by(name: "Shop")
- milestone = project.milestones.find_by(title: 'v2.2')
-
- # 3 Open issues created above; create one closed issue
- create(:closed_issue, project: project, milestone: milestone)
- end
-
- step 'I should see deleted milestone activity' do
- expect(page).to have_content('opened milestone in')
- expect(page).to have_content('destroyed milestone in')
- end
-
When 'I click link "All Issues"' do
click_link 'All Issues'
end
-
- step 'I should see 3 issues' do
- expect(page).to have_selector('#tab-issues li.issuable-row', count: 4)
- end
-
- step 'I click button to remove milestone' do
- click_button 'Delete'
- end
-
- step 'I confirm in modal' do
- click_button 'Delete milestone'
- end
-
- step 'I should see no milestones' do
- expect(page).to have_content('No milestones to show')
- end
end
diff --git a/features/steps/project/project.rb b/features/steps/project/project.rb
deleted file mode 100644
index bba30a72325..00000000000
--- a/features/steps/project/project.rb
+++ /dev/null
@@ -1,154 +0,0 @@
-class Spinach::Features::Project < Spinach::FeatureSteps
- include SharedAuthentication
- include SharedProject
- include SharedPaths
- include WaitForRequests
-
- step 'change project settings' do
- fill_in 'project_name_edit', with: 'NewName'
- end
-
- step 'I save project' do
- page.within '.general-settings' do
- click_button 'Save changes'
- end
- end
-
- step 'I should see project with new settings' do
- expect(find_field('project_name').value).to eq 'NewName'
- end
-
- step 'change project path settings' do
- fill_in 'project_path', with: 'new-path'
- click_button 'Rename'
- end
-
- step 'I should see project with new path settings' do
- expect(project.path).to eq 'new-path'
- end
-
- step 'I change the project avatar' do
- attach_file(
- :project_avatar,
- File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
- )
- page.within '.general-settings' do
- click_button 'Save changes'
- end
- @project.reload
- end
-
- step 'I should see new project avatar' do
- expect(@project.avatar).to be_instance_of AvatarUploader
- url = @project.avatar.url
- expect(url).to eq "/uploads/-/system/project/avatar/#{@project.id}/banana_sample.gif"
- end
-
- step 'I should see the "Remove avatar" button' do
- expect(page).to have_link('Remove avatar')
- end
-
- step 'I have an project avatar' do
- attach_file(
- :project_avatar,
- File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
- )
- page.within '.general-settings' do
- click_button 'Save changes'
- end
- @project.reload
- end
-
- step 'I remove my project avatar' do
- click_link 'Remove avatar'
- @project.reload
- end
-
- step 'I should see the default project avatar' do
- expect(@project.avatar?).to eq false
- end
-
- step 'I should not see the "Remove avatar" button' do
- expect(page).not_to have_link('Remove avatar')
- end
-
- step 'change project default branch' do
- select 'fix', from: 'project_default_branch'
- page.within '.general-settings' do
- click_button 'Save changes'
- end
- end
-
- step 'I should see project default branch changed' do
- expect(find(:css, 'select#project_default_branch').value).to eq 'fix'
- end
-
- step 'I select project "Forum" README tab' do
- click_link 'Readme'
- end
-
- step 'I should see project "Forum" README' do
- page.within('.readme-holder') do
- expect(page).to have_content 'Sample repo for testing gitlab features'
- end
- end
-
- step 'I should see project "Shop" README' do
- wait_for_requests
- page.within('.readme-holder') do
- expect(page).to have_content 'testme'
- end
- end
-
- step 'I add project tags' do
- fill_in 'Tags', with: 'tag1, tag2'
- end
-
- step 'I should see project tags' do
- expect(find_field('Tags').value).to eq 'tag1, tag2'
- end
-
- step 'I should not see "New Issue" button' do
- expect(page).not_to have_link 'New Issue'
- end
-
- step 'I should not see "New Merge Request" button' do
- expect(page).not_to have_link 'New Merge Request'
- end
-
- step 'I should not see "Snippets" button' do
- page.within '.content' do
- expect(page).not_to have_link 'Snippets'
- end
- end
-
- step 'project "Shop" belongs to group' do
- group = create(:group)
- @project.namespace = group
- @project.save!
- end
-
- step 'I click notifications drop down button' do
- first('.notifications-btn').click
- end
-
- step 'I choose Mention setting' do
- click_link 'On mention'
- end
-
- step 'I should see Notification saved message' do
- page.within '#notifications-button' do
- expect(page).to have_content 'On mention'
- end
- end
-
- step 'I create bare repo' do
- click_link 'Create empty repository'
- end
-
- step 'I should see command line instructions' do
- page.within ".empty_wrapper" do
- expect(page).to have_content("Command line instructions")
- end
- end
-end
diff --git a/features/steps/shared/markdown.rb b/features/steps/shared/markdown.rb
index c66280127e9..9d522936fb6 100644
--- a/features/steps/shared/markdown.rb
+++ b/features/steps/shared/markdown.rb
@@ -10,10 +10,6 @@ module SharedMarkdown
expect(find(:xpath, "#{node.path}/..").text).to eq text
end
- step 'Header "Description header" should have correct id and link' do
- header_should_have_correct_id_and_link(1, 'Description header', 'description-header')
- end
-
step 'I should not see the Markdown preview' do
expect(find('.gfm-form .js-md-preview')).not_to be_visible
end
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index cc893b8391e..3b4c839bcef 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -264,10 +264,6 @@ module SharedPaths
visit project_path(project)
end
- step 'I visit project "Shop" activity page' do
- visit activity_project_path(project)
- end
-
step 'I visit project "Forked Shop" merge requests page' do
visit project_merge_requests_path(@forked_project)
end
@@ -276,14 +272,6 @@ module SharedPaths
visit edit_project_path(project)
end
- step 'I visit project branches page' do
- visit project_branches_path(@project)
- end
-
- step 'I visit project protected branches page' do
- visit project_protected_branches_path(@project)
- end
-
step 'I visit compare refs page' do
visit project_compare_index_path(@project)
end
@@ -381,10 +369,6 @@ module SharedPaths
visit project_merge_requests_path(project)
end
- step 'I visit project "Shop" milestones page' do
- visit project_milestones_path(project)
- end
-
step 'I visit project "Shop" team page' do
visit project_project_members_path(project)
end
diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb
index be848ebafa0..09969a6473f 100644
--- a/features/steps/shared/project.rb
+++ b/features/steps/shared/project.rb
@@ -25,72 +25,6 @@ module SharedProject
@project.add_master(@user)
end
- step 'I disable snippets in project' do
- @project.snippets_enabled = false
- @project.save
- end
-
- step 'I disable issues and merge requests in project' do
- @project.issues_enabled = false
- @project.merge_requests_enabled = false
- @project.save
- end
-
- # Add another user to project "Shop"
- step 'I add a user to project "Shop"' do
- @project = Project.find_by(name: "Shop")
- other_user = create(:user, name: 'Alpha')
- @project.add_master(other_user)
- end
-
- # Create another specific project called "Forum"
- step 'I own project "Forum"' do
- @project = Project.find_by(name: "Forum")
- @project ||= create(:project, :repository, name: "Forum", namespace: @user.namespace, path: 'forum_project')
- @project.build_project_feature
- @project.project_feature.save
- @project.add_master(@user)
- end
-
- # Create an empty project without caring about the name
- step 'I own an empty project' do
- @project = create(:project, name: 'Empty Project', namespace: @user.namespace)
- @project.add_master(@user)
- end
-
- step 'I visit my empty project page' do
- project = Project.find_by(name: 'Empty Project')
- visit project_path(project)
- end
-
- step 'I visit project "Shop" activity page' do
- project = Project.find_by(name: 'Shop')
- visit project_path(project)
- end
-
- step 'project "Shop" has push event' do
- @project = Project.find_by(name: "Shop")
- @event = create(:push_event, project: @project, author: @user)
-
- create(:push_event_payload,
- event: @event,
- action: :created,
- commit_to: '6d394385cf567f80a8fd85055db1ab4c5295806f',
- ref: 'fix',
- commit_count: 1)
- end
-
- step 'I should see project "Shop" activity feed' do
- project = Project.find_by(name: "Shop")
- expect(page).to have_content "#{@user.name} pushed new branch fix at #{project.full_name}"
- end
-
- step 'I should see project settings' do
- expect(current_path).to eq edit_project_path(@project)
- expect(page).to have_content("Project name")
- expect(page).to have_content("Permissions")
- end
-
def current_project
@project ||= Project.first
end
@@ -206,24 +140,6 @@ module SharedProject
create(:label, project: project, title: 'enhancement')
end
- step 'project "Shop" has CI enabled' do
- project = Project.find_by(name: "Shop")
- project.enable_ci
- end
-
- step 'project "Shop" has CI build' do
- project = Project.find_by(name: "Shop")
- pipeline = create :ci_pipeline, project: project, sha: project.commit.sha, ref: 'master'
- pipeline.skip
- end
-
- step 'I should see last commit with CI status' do
- page.within ".blob-commit-info" do
- expect(page).to have_content(project.commit.sha[0..6])
- expect(page).to have_link("Commit: skipped")
- end
- end
-
step 'The project is internal' do
@project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 3264a26f7d2..d4cc18f622b 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -189,7 +189,7 @@ module API
post ":id/merge_requests" do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42316')
- authorize! :create_merge_request, user_project
+ authorize! :create_merge_request_from, user_project
mr_params = declared_params(include_missing: false)
mr_params[:force_remove_source_branch] = mr_params.delete(:remove_source_branch)
diff --git a/lib/api/v3/merge_requests.rb b/lib/api/v3/merge_requests.rb
index ce216497996..9b0f70e2bfe 100644
--- a/lib/api/v3/merge_requests.rb
+++ b/lib/api/v3/merge_requests.rb
@@ -93,7 +93,7 @@ module API
post ":id/merge_requests" do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42126')
- authorize! :create_merge_request, user_project
+ authorize! :create_merge_request_from, user_project
mr_params = declared_params(include_missing: false)
mr_params[:force_remove_source_branch] = mr_params.delete(:remove_source_branch) if mr_params[:remove_source_branch].present?
diff --git a/lib/banzai/commit_renderer.rb b/lib/banzai/commit_renderer.rb
index f5ff95e3eb3..c351a155ae5 100644
--- a/lib/banzai/commit_renderer.rb
+++ b/lib/banzai/commit_renderer.rb
@@ -3,7 +3,7 @@ module Banzai
ATTRIBUTES = [:description, :title].freeze
def self.render(commits, project, user = nil)
- obj_renderer = ObjectRenderer.new(project, user)
+ obj_renderer = ObjectRenderer.new(user: user, default_project: project)
ATTRIBUTES.each { |attr| obj_renderer.render(commits, attr) }
end
diff --git a/lib/banzai/filter/issuable_state_filter.rb b/lib/banzai/filter/issuable_state_filter.rb
index 8f541dcfdb2..1a415232545 100644
--- a/lib/banzai/filter/issuable_state_filter.rb
+++ b/lib/banzai/filter/issuable_state_filter.rb
@@ -11,7 +11,8 @@ module Banzai
def call
return doc unless context[:issuable_state_filter_enabled]
- extractor = Banzai::IssuableExtractor.new(project, current_user)
+ context = RenderContext.new(project, current_user)
+ extractor = Banzai::IssuableExtractor.new(context)
issuables = extractor.extract([doc])
issuables.each do |node, issuable|
diff --git a/lib/banzai/filter/redactor_filter.rb b/lib/banzai/filter/redactor_filter.rb
index 9f9882b3b40..caf11fe94c4 100644
--- a/lib/banzai/filter/redactor_filter.rb
+++ b/lib/banzai/filter/redactor_filter.rb
@@ -7,7 +7,11 @@ module Banzai
#
class RedactorFilter < HTML::Pipeline::Filter
def call
- Redactor.new(project, current_user).redact([doc]) unless context[:skip_redaction]
+ unless context[:skip_redaction]
+ context = RenderContext.new(project, current_user)
+
+ Redactor.new(context).redact([doc])
+ end
doc
end
diff --git a/lib/banzai/issuable_extractor.rb b/lib/banzai/issuable_extractor.rb
index 49603d0b363..ae7dc71e7eb 100644
--- a/lib/banzai/issuable_extractor.rb
+++ b/lib/banzai/issuable_extractor.rb
@@ -12,11 +12,11 @@ module Banzai
[@data-reference-type="issue" or @data-reference-type="merge_request"]
).freeze
- attr_reader :project, :user
+ attr_reader :context
- def initialize(project, user)
- @project = project
- @user = user
+ # context - An instance of Banzai::RenderContext.
+ def initialize(context)
+ @context = context
end
# Returns Hash in the form { node => issuable_instance }
@@ -25,8 +25,10 @@ module Banzai
document.xpath(QUERY)
end
- issue_parser = Banzai::ReferenceParser::IssueParser.new(project, user)
- merge_request_parser = Banzai::ReferenceParser::MergeRequestParser.new(project, user)
+ issue_parser = Banzai::ReferenceParser::IssueParser.new(context)
+
+ merge_request_parser =
+ Banzai::ReferenceParser::MergeRequestParser.new(context)
issuables_for_nodes = issue_parser.records_for_nodes(nodes).merge(
merge_request_parser.records_for_nodes(nodes)
diff --git a/lib/banzai/object_renderer.rb b/lib/banzai/object_renderer.rb
index 2691be81623..a176f1e261b 100644
--- a/lib/banzai/object_renderer.rb
+++ b/lib/banzai/object_renderer.rb
@@ -13,14 +13,13 @@ module Banzai
# As an example, rendering the attribute `note` would place the unredacted
# HTML into `note_html` and the redacted HTML into `redacted_note_html`.
class ObjectRenderer
- attr_reader :project, :user
+ attr_reader :context
- # project - A Project to use for redacting Markdown.
+ # default_project - A default Project to use for redacting Markdown.
# user - The user viewing the Markdown/HTML documents, if any.
# redaction_context - A Hash containing extra attributes to use during redaction
- def initialize(project, user = nil, redaction_context = {})
- @project = project
- @user = user
+ def initialize(default_project: nil, user: nil, redaction_context: {})
+ @context = RenderContext.new(default_project, user)
@redaction_context = base_context.merge(redaction_context)
end
@@ -48,17 +47,21 @@ module Banzai
pipeline = HTML::Pipeline.new([])
objects.map do |object|
- pipeline.to_document(Banzai.render_field(object, attribute))
+ document = pipeline.to_document(Banzai.render_field(object, attribute))
+
+ context.associate_document(document, object)
+
+ document
end
end
def post_process_documents(documents, objects, attribute)
# Called here to populate cache, refer to IssuableExtractor docs
- IssuableExtractor.new(project, user).extract(documents)
+ IssuableExtractor.new(context).extract(documents)
documents.zip(objects).map do |document, object|
- context = context_for(object, attribute)
- Banzai::Pipeline[:post_process].to_document(document, context)
+ pipeline_context = context_for(document, object, attribute)
+ Banzai::Pipeline[:post_process].to_document(document, pipeline_context)
end
end
@@ -66,20 +69,21 @@ module Banzai
#
# Returns an Array containing the redacted documents.
def redact_documents(documents)
- redactor = Redactor.new(project, user)
+ redactor = Redactor.new(context)
redactor.redact(documents)
end
# Returns a Banzai context for the given object and attribute.
- def context_for(object, attribute)
- @redaction_context.merge(object.banzai_render_context(attribute))
+ def context_for(document, object, attribute)
+ @redaction_context.merge(object.banzai_render_context(attribute)).merge(
+ project: context.project_for_node(document)
+ )
end
def base_context
{
- current_user: user,
- project: project,
+ current_user: context.current_user,
skip_redaction: true
}
end
diff --git a/lib/banzai/redactor.rb b/lib/banzai/redactor.rb
index fd457bebf03..28928d6f376 100644
--- a/lib/banzai/redactor.rb
+++ b/lib/banzai/redactor.rb
@@ -2,13 +2,15 @@ module Banzai
# Class for removing Markdown references a certain user is not allowed to
# view.
class Redactor
- attr_reader :user, :project
+ attr_reader :context
- # project - A Project to use for redacting links.
- # user - The currently logged in user (if any).
- def initialize(project, user = nil)
- @project = project
- @user = user
+ # context - An instance of `Banzai::RenderContext`.
+ def initialize(context)
+ @context = context
+ end
+
+ def user
+ context.current_user
end
# Redacts the references in the given Array of documents.
@@ -70,11 +72,11 @@ module Banzai
end
def redact_cross_project_references(documents)
- extractor = Banzai::IssuableExtractor.new(project, user)
+ extractor = Banzai::IssuableExtractor.new(context)
issuables = extractor.extract(documents)
issuables.each do |node, issuable|
- next if issuable.project == project
+ next if issuable.project == context.project_for_node(node)
node['class'] = node['class'].gsub('has-tooltip', '')
node['title'] = nil
@@ -95,7 +97,7 @@ module Banzai
end
per_type.each do |type, nodes|
- parser = Banzai::ReferenceParser[type].new(project, user)
+ parser = Banzai::ReferenceParser[type].new(context)
visible.merge(parser.nodes_visible_to_user(user, nodes))
end
diff --git a/lib/banzai/reference_extractor.rb b/lib/banzai/reference_extractor.rb
index 7e6357f8a00..78588299c18 100644
--- a/lib/banzai/reference_extractor.rb
+++ b/lib/banzai/reference_extractor.rb
@@ -10,8 +10,8 @@ module Banzai
end
def references(type, project, current_user = nil)
- processor = Banzai::ReferenceParser[type]
- .new(project, current_user)
+ context = RenderContext.new(project, current_user)
+ processor = Banzai::ReferenceParser[type].new(context)
processor.process(html_documents)
end
diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb
index 279fca8d043..68752f5bb5a 100644
--- a/lib/banzai/reference_parser/base_parser.rb
+++ b/lib/banzai/reference_parser/base_parser.rb
@@ -45,9 +45,13 @@ module Banzai
@data_attribute ||= "data-#{reference_type.to_s.dasherize}"
end
- def initialize(project = nil, current_user = nil)
- @project = project
- @current_user = current_user
+ # context - An instance of `Banzai::RenderContext`.
+ def initialize(context)
+ @context = context
+ end
+
+ def project_for_node(node)
+ context.project_for_node(node)
end
# Returns all the nodes containing references that the user can refer to.
@@ -224,7 +228,11 @@ module Banzai
private
- attr_reader :current_user, :project
+ attr_reader :context
+
+ def current_user
+ context.current_user
+ end
# When a feature is disabled or visible only for
# team members we should not allow team members
diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb
index 230827129b6..6bee5ea15b9 100644
--- a/lib/banzai/reference_parser/issue_parser.rb
+++ b/lib/banzai/reference_parser/issue_parser.rb
@@ -5,15 +5,10 @@ module Banzai
def nodes_visible_to_user(user, nodes)
issues = records_for_nodes(nodes)
- issues_to_check = issues.values
+ issues_to_check, cross_project_issues = partition_issues(issues, user)
- unless can?(user, :read_cross_project)
- issues_to_check, cross_project_issues = issues_to_check.partition do |issue|
- issue.project == project
- end
- end
-
- readable_issues = Ability.issues_readable_by_user(issues_to_check, user).to_set
+ readable_issues =
+ Ability.issues_readable_by_user(issues_to_check, user).to_set
nodes.select do |node|
issue_in_node = issues[node]
@@ -25,7 +20,7 @@ module Banzai
# but not the issue.
if readable_issues.include?(issue_in_node)
true
- elsif cross_project_issues&.include?(issue_in_node)
+ elsif cross_project_issues.include?(issue_in_node)
can_read_reference?(user, issue_in_node)
else
false
@@ -33,6 +28,32 @@ module Banzai
end
end
+ # issues - A Hash mapping HTML nodes to their corresponding Issue
+ # instances.
+ # user - The current User.
+ def partition_issues(issues, user)
+ return [issues.values, []] if can?(user, :read_cross_project)
+
+ issues_to_check = []
+ cross_project_issues = []
+
+ # We manually partition the data since our input is a Hash and our
+ # output has to be an Array of issues; not an Array of (node, issue)
+ # pairs.
+ issues.each do |node, issue|
+ target =
+ if issue.project == project_for_node(node)
+ issues_to_check
+ else
+ cross_project_issues
+ end
+
+ target << issue
+ end
+
+ [issues_to_check, cross_project_issues]
+ end
+
def records_for_nodes(nodes)
@issues_for_nodes ||= grouped_objects_for_nodes(
nodes,
diff --git a/lib/banzai/reference_parser/user_parser.rb b/lib/banzai/reference_parser/user_parser.rb
index 8932d4f2905..ceb7f1d165c 100644
--- a/lib/banzai/reference_parser/user_parser.rb
+++ b/lib/banzai/reference_parser/user_parser.rb
@@ -58,7 +58,7 @@ module Banzai
def can_read_project_reference?(node)
node_id = node.attr('data-project').to_i
- project && project.id == node_id
+ project_for_node(node)&.id == node_id
end
def nodes_user_can_reference(current_user, nodes)
@@ -71,6 +71,7 @@ module Banzai
nodes.select do |node|
project_id = node.attr(project_attr)
user_id = node.attr(author_attr)
+ project = project_for_node(node)
if project && project_id && project.id == project_id.to_i
true
diff --git a/lib/banzai/render_context.rb b/lib/banzai/render_context.rb
new file mode 100644
index 00000000000..e30fc9f469b
--- /dev/null
+++ b/lib/banzai/render_context.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Banzai
+ # Object storing the current user, project, and other details used when
+ # parsing Markdown references.
+ class RenderContext
+ attr_reader :current_user
+
+ # default_project - The default project to use for all documents, if any.
+ # current_user - The user viewing the document, if any.
+ def initialize(default_project = nil, current_user = nil)
+ @current_user = current_user
+ @projects = Hash.new(default_project)
+ end
+
+ # Associates an HTML document with a Project.
+ #
+ # document - The HTML document to map to a Project.
+ # object - The object that produced the HTML document.
+ def associate_document(document, object)
+ # XML nodes respond to "document" but will return a Document instance,
+ # even when they belong to a DocumentFragment.
+ document = document.document if document.fragment?
+
+ @projects[document] = object.project if object.respond_to?(:project)
+ end
+
+ def project_for_node(node)
+ @projects[node.document]
+ end
+ end
+end
diff --git a/lib/gitlab/ci/status/build/common.rb b/lib/gitlab/ci/status/build/common.rb
index c0c7c7f5b5d..c1fc70ac266 100644
--- a/lib/gitlab/ci/status/build/common.rb
+++ b/lib/gitlab/ci/status/build/common.rb
@@ -3,6 +3,14 @@ module Gitlab
module Status
module Build
module Common
+ def illustration
+ {
+ image: 'illustrations/skipped-job_empty.svg',
+ size: 'svg-430',
+ title: _('This job does not have a trace.')
+ }
+ end
+
def has_details?
can?(user, :read_build, subject)
end
diff --git a/lib/gitlab/ci/status/build/erased.rb b/lib/gitlab/ci/status/build/erased.rb
index 3a5113b16b6..495227c2ffb 100644
--- a/lib/gitlab/ci/status/build/erased.rb
+++ b/lib/gitlab/ci/status/build/erased.rb
@@ -5,7 +5,7 @@ module Gitlab
class Erased < Status::Extended
def illustration
{
- image: 'illustrations/skipped-job_empty.svg',
+ image: 'illustrations/erased-log_empty.svg',
size: 'svg-430',
title: _('Job has been erased')
}
diff --git a/lib/gitlab/ci/variables/collection/item.rb b/lib/gitlab/ci/variables/collection/item.rb
index 23ed71db8b0..d00e5b07f95 100644
--- a/lib/gitlab/ci/variables/collection/item.rb
+++ b/lib/gitlab/ci/variables/collection/item.rb
@@ -3,12 +3,9 @@ module Gitlab
module Variables
class Collection
class Item
- def initialize(**options)
+ def initialize(key:, value:, public: true, file: false)
@variable = {
- key: options.fetch(:key),
- value: options.fetch(:value),
- public: options.fetch(:public, true),
- file: options.fetch(:files, false)
+ key: key, value: value, public: public, file: file
}
end
diff --git a/lib/gitlab/email/handler/create_merge_request_handler.rb b/lib/gitlab/email/handler/create_merge_request_handler.rb
index 3436306e122..2f864f2082b 100644
--- a/lib/gitlab/email/handler/create_merge_request_handler.rb
+++ b/lib/gitlab/email/handler/create_merge_request_handler.rb
@@ -23,7 +23,8 @@ module Gitlab
def execute
raise ProjectNotFound unless project
- validate_permission!(:create_merge_request)
+ validate_permission!(:create_merge_request_in)
+ validate_permission!(:create_merge_request_from)
verify_record!(
record: create_merge_request,
diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb
index d4e893b881c..c9abea90d21 100644
--- a/lib/gitlab/git.rb
+++ b/lib/gitlab/git.rb
@@ -1,5 +1,9 @@
module Gitlab
module Git
+ # The ID of empty tree.
+ # See http://stackoverflow.com/a/40884093/1856239 and
+ # https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012
+ EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze
BLANK_SHA = ('0' * 40).freeze
TAG_REF_PREFIX = "refs/tags/".freeze
BRANCH_REF_PREFIX = "refs/heads/".freeze
diff --git a/lib/gitlab/git/attributes_parser.rb b/lib/gitlab/git/attributes_parser.rb
index d8aeabb6cba..08f4d7d4f5c 100644
--- a/lib/gitlab/git/attributes_parser.rb
+++ b/lib/gitlab/git/attributes_parser.rb
@@ -3,12 +3,8 @@ module Gitlab
# Class for parsing Git attribute files and extracting the attributes for
# file patterns.
class AttributesParser
- def initialize(attributes_data)
+ def initialize(attributes_data = "")
@data = attributes_data || ""
-
- if @data.is_a?(File)
- @patterns = parse_file
- end
end
# Returns all the Git attributes for the given path.
@@ -28,7 +24,7 @@ module Gitlab
# Returns a Hash containing the file patterns and their attributes.
def patterns
- @patterns ||= parse_file
+ @patterns ||= parse_data
end
# Parses an attribute string.
@@ -91,8 +87,8 @@ module Gitlab
private
- # Parses the Git attributes file.
- def parse_file
+ # Parses the Git attributes file contents.
+ def parse_data
pairs = []
comment = '#'
diff --git a/lib/gitlab/git/info_attributes.rb b/lib/gitlab/git/info_attributes.rb
deleted file mode 100644
index e79a440950b..00000000000
--- a/lib/gitlab/git/info_attributes.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# Gitaly note: JV: not sure what to make of this class. Why does it use
-# the full disk path of the repository to look up attributes This is
-# problematic in Gitaly, because Gitaly hides the full disk path to the
-# repository from gitlab-ce.
-
-module Gitlab
- module Git
- # Parses gitattributes at `$GIT_DIR/info/attributes`
- #
- # Unlike Rugged this parser only needs a single IO call (a call to `open`),
- # vastly reducing the time spent in extracting attributes.
- #
- # This class _only_ supports parsing the attributes file located at
- # `$GIT_DIR/info/attributes` as GitLab doesn't use any other files
- # (`.gitattributes` is copied to this particular path).
- #
- # Basic usage:
- #
- # attributes = Gitlab::Git::InfoAttributes.new(some_repo.path)
- #
- # attributes.attributes('README.md') # => { "eol" => "lf }
- class InfoAttributes
- delegate :attributes, :patterns, to: :parser
-
- # path - The path to the Git repository.
- def initialize(path)
- @repo_path = File.expand_path(path)
- end
-
- def parser
- @parser ||= begin
- if File.exist?(attributes_path)
- File.open(attributes_path, 'r') do |file_handle|
- AttributesParser.new(file_handle)
- end
- else
- AttributesParser.new("")
- end
- end
- end
-
- private
-
- def attributes_path
- @attributes_path ||= File.join(@repo_path, 'info/attributes')
- end
- end
- end
-end
diff --git a/lib/gitlab/git/raw_diff_change.rb b/lib/gitlab/git/raw_diff_change.rb
new file mode 100644
index 00000000000..eb3d8819239
--- /dev/null
+++ b/lib/gitlab/git/raw_diff_change.rb
@@ -0,0 +1,60 @@
+module Gitlab
+ module Git
+ # This class behaves like a struct with fields :blob_id, :blob_size, :operation, :old_path, :new_path
+ # All those fields are (binary) strings or integers
+ class RawDiffChange
+ attr_reader :blob_id, :blob_size, :old_path, :new_path, :operation
+
+ def initialize(raw_change)
+ parse(raw_change)
+ end
+
+ private
+
+ # Input data has the following format:
+ #
+ # When a file has been modified:
+ # 7e3e39ebb9b2bf433b4ad17313770fbe4051649c 669 M\tfiles/ruby/popen.rb
+ #
+ # When a file has been renamed:
+ # 85bc2f9753afd5f4fc5d7c75f74f8d526f26b4f3 107 R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee
+ def parse(raw_change)
+ @blob_id, @blob_size, @raw_operation, raw_paths = raw_change.split(' ', 4)
+ @operation = extract_operation
+ @old_path, @new_path = extract_paths(raw_paths)
+ end
+
+ def extract_paths(file_path)
+ case operation
+ when :renamed
+ file_path.split(/\t/)
+ when :deleted
+ [file_path, nil]
+ when :added
+ [nil, file_path]
+ else
+ [file_path, file_path]
+ end
+ end
+
+ def extract_operation
+ case @raw_operation&.first(1)
+ when 'A'
+ :added
+ when 'C'
+ :copied
+ when 'D'
+ :deleted
+ when 'M'
+ :modified
+ when 'R'
+ :renamed
+ when 'T'
+ :type_changed
+ else
+ :unknown
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index f1b575bd872..36992cbcca0 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -105,7 +105,6 @@ module Gitlab
)
@path = File.join(storage_path, @relative_path)
@name = @relative_path.split("/").last
- @attributes = Gitlab::Git::InfoAttributes.new(path)
end
def ==(other)
@@ -559,6 +558,24 @@ module Gitlab
count_commits(from: from, to: to, **options)
end
+ # old_rev and new_rev are commit ID's
+ # the result of this method is an array of Gitlab::Git::RawDiffChange
+ def raw_changes_between(old_rev, new_rev)
+ result = []
+
+ circuit_breaker.perform do
+ Open3.pipeline_r(git_diff_cmd(old_rev, new_rev), format_git_cat_file_script, git_cat_file_cmd) do |last_stdout, wait_threads|
+ last_stdout.each_line { |line| result << ::Gitlab::Git::RawDiffChange.new(line.chomp!) }
+
+ if wait_threads.any? { |waiter| !waiter.value&.success? }
+ raise ::Gitlab::Git::Repository::GitError, "Unabled to obtain changes between #{old_rev} and #{new_rev}"
+ end
+ end
+ end
+
+ result
+ end
+
# Returns the SHA of the most recent common ancestor of +from+ and +to+
def merge_base(from, to)
gitaly_migrate(:merge_base) do |is_enabled|
@@ -993,11 +1010,32 @@ module Gitlab
raise InvalidRef
end
+ def info_attributes
+ return @info_attributes if @info_attributes
+
+ content =
+ gitaly_migrate(:get_info_attributes) do |is_enabled|
+ if is_enabled
+ gitaly_repository_client.info_attributes
+ else
+ attributes_path = File.join(File.expand_path(@path), 'info', 'attributes')
+
+ if File.exist?(attributes_path)
+ File.read(attributes_path)
+ else
+ ""
+ end
+ end
+ end
+
+ @info_attributes = AttributesParser.new(content)
+ end
+
# Returns the Git attributes for the given file path.
#
# See `Gitlab::Git::Attributes` for more information.
def attributes(path)
- @attributes.attributes(path)
+ info_attributes.attributes(path)
end
def gitattribute(path, name)
@@ -1385,7 +1423,8 @@ module Gitlab
end
def branch_names_contains_sha(sha)
- gitaly_migrate(:branch_names_contains_sha) do |is_enabled|
+ gitaly_migrate(:branch_names_contains_sha,
+ status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled
gitaly_ref_client.branch_names_contains_sha(sha)
else
@@ -1395,7 +1434,8 @@ module Gitlab
end
def tag_names_contains_sha(sha)
- gitaly_migrate(:tag_names_contains_sha) do |is_enabled|
+ gitaly_migrate(:tag_names_contains_sha,
+ status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled
gitaly_ref_client.tag_names_contains_sha(sha)
else
@@ -2461,6 +2501,35 @@ module Gitlab
result.to_s(16)
end
+
+ def build_git_cmd(*args)
+ object_directories = alternate_object_directories.join(File::PATH_SEPARATOR)
+
+ env = { 'PWD' => self.path }
+ env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = object_directories if object_directories.present?
+
+ [
+ env,
+ ::Gitlab.config.git.bin_path,
+ *args,
+ { chdir: self.path }
+ ]
+ end
+
+ def git_diff_cmd(old_rev, new_rev)
+ old_rev = old_rev == ::Gitlab::Git::BLANK_SHA ? ::Gitlab::Git::EMPTY_TREE_ID : old_rev
+
+ build_git_cmd('diff', old_rev, new_rev, '--raw')
+ end
+
+ def git_cat_file_cmd
+ format = '%(objectname) %(objectsize) %(rest)'
+ build_git_cmd('cat-file', "--batch-check=#{format}")
+ end
+
+ def format_git_cat_file_script
+ File.expand_path('../support/format-git-cat-file-input', __FILE__)
+ end
end
end
end
diff --git a/lib/gitlab/git/support/format-git-cat-file-input b/lib/gitlab/git/support/format-git-cat-file-input
new file mode 100755
index 00000000000..2e93c646d0f
--- /dev/null
+++ b/lib/gitlab/git/support/format-git-cat-file-input
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+
+# This script formats the output of the `git diff <old_rev> <new_rev> --raw`
+# command so it can be processed by `git cat-file`
+
+# We need to convert this:
+# ":100644 100644 5f53439... 85bc2f9... R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee"
+# To:
+# "85bc2f9 R\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee"
+
+ARGF.each do |line|
+ _, _, old_blob_id, new_blob_id, rest = line.split(/\s/, 5)
+
+ old_blob_id.gsub!(/[^\h]/, '')
+ new_blob_id.gsub!(/[^\h]/, '')
+
+ # We can't pass '0000000...' to `git cat-file` given it will not return info about the deleted file
+ blob_id = new_blob_id =~ /\A0+\z/ ? old_blob_id : new_blob_id
+
+ $stdout.puts "#{blob_id} #{rest}"
+end
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index 456a8a1a2d6..a36e6c822f9 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -3,10 +3,6 @@ module Gitlab
class CommitService
include Gitlab::EncodingHelper
- # The ID of empty tree.
- # See http://stackoverflow.com/a/40884093/1856239 and https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012
- EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze
-
def initialize(repository)
@gitaly_repo = repository.gitaly_repository
@repository = repository
@@ -37,7 +33,7 @@ module Gitlab
def diff(from, to, options = {})
from_id = case from
when NilClass
- EMPTY_TREE_ID
+ Gitlab::Git::EMPTY_TREE_ID
else
if from.respond_to?(:oid)
# This is meant to match a Rugged::Commit. This should be impossible in
@@ -50,7 +46,7 @@ module Gitlab
to_id = case to
when NilClass
- EMPTY_TREE_ID
+ Gitlab::Git::EMPTY_TREE_ID
else
if to.respond_to?(:oid)
# This is meant to match a Rugged::Commit. This should be impossible in
@@ -352,7 +348,7 @@ module Gitlab
end
def diff_from_parent_request_params(commit, options = {})
- parent_id = commit.parent_ids.first || EMPTY_TREE_ID
+ parent_id = commit.parent_ids.first || Gitlab::Git::EMPTY_TREE_ID
diff_between_commits_request_params(parent_id, commit.id, options)
end
diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb
index 6441065f5fe..39057beefba 100644
--- a/lib/gitlab/gitaly_client/repository_service.rb
+++ b/lib/gitlab/gitaly_client/repository_service.rb
@@ -50,6 +50,15 @@ module Gitlab
GitalyClient.call(@storage, :repository_service, :apply_gitattributes, request)
end
+ def info_attributes
+ request = Gitaly::GetInfoAttributesRequest.new(repository: @gitaly_repo)
+
+ response = GitalyClient.call(@storage, :repository_service, :get_info_attributes, request)
+ response.each_with_object("") do |message, attributes|
+ attributes << message.attributes
+ end
+ end
+
def fetch_remote(remote, ssh_auth:, forced:, no_tags:, timeout:, prune: true)
request = Gitaly::FetchRemoteRequest.new(
repository: @gitaly_repo, remote: remote, force: forced,
diff --git a/lib/gitlab/gitaly_client/wiki_service.rb b/lib/gitlab/gitaly_client/wiki_service.rb
index 0d8dd5cb8f4..7a698e4b3f3 100644
--- a/lib/gitlab/gitaly_client/wiki_service.rb
+++ b/lib/gitlab/gitaly_client/wiki_service.rb
@@ -136,7 +136,7 @@ module Gitlab
wiki_file = nil
response.each do |message|
- next unless message.name.present?
+ next unless message.name.present? || wiki_file
if wiki_file
wiki_file.raw_data << message.raw_data
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 24393f96d96..69952cbb47c 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -51,7 +51,7 @@ module Gitlab
return false unless can_access_git?
if protected?(ProtectedBranch, project, ref)
- user.can?(:delete_protected_branch, project)
+ user.can?(:push_to_delete_protected_branch, project)
else
user.can?(:push_code, project)
end
diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb
index b0a492eaa58..aeda66763e8 100644
--- a/lib/gitlab/utils.rb
+++ b/lib/gitlab/utils.rb
@@ -73,6 +73,10 @@ module Gitlab
nil
end
+ def bytes_to_megabytes(bytes)
+ bytes.to_f / Numeric::MEGABYTE
+ end
+
# Used in EE
# Accepts either an Array or a String and returns an array
def ensure_array_from_string(string_or_array)
diff --git a/lib/rspec_flaky/config.rb b/lib/rspec_flaky/config.rb
index a17ae55910e..06e96f969f1 100644
--- a/lib/rspec_flaky/config.rb
+++ b/lib/rspec_flaky/config.rb
@@ -1,9 +1,7 @@
-require 'json'
-
module RspecFlaky
class Config
def self.generate_report?
- ENV['FLAKY_RSPEC_GENERATE_REPORT'] == 'true'
+ !!(ENV['FLAKY_RSPEC_GENERATE_REPORT'] =~ /1|true/)
end
def self.suite_flaky_examples_report_path
diff --git a/lib/rspec_flaky/flaky_examples_collection.rb b/lib/rspec_flaky/flaky_examples_collection.rb
index 973c95b0212..dea23c325be 100644
--- a/lib/rspec_flaky/flaky_examples_collection.rb
+++ b/lib/rspec_flaky/flaky_examples_collection.rb
@@ -1,11 +1,9 @@
-require 'json'
+require 'active_support/hash_with_indifferent_access'
+
+require_relative 'flaky_example'
module RspecFlaky
class FlakyExamplesCollection < SimpleDelegator
- def self.from_json(json)
- new(JSON.parse(json))
- end
-
def initialize(collection = {})
unless collection.is_a?(Hash)
raise ArgumentError, "`collection` must be a Hash, #{collection.class} given!"
@@ -22,7 +20,7 @@ module RspecFlaky
super(Hash[collection_of_flaky_examples])
end
- def to_report
+ def to_h
Hash[map { |uid, example| [uid, example.to_h] }].deep_symbolize_keys
end
diff --git a/lib/rspec_flaky/listener.rb b/lib/rspec_flaky/listener.rb
index 4a5bfec9967..5b5e4f7c7de 100644
--- a/lib/rspec_flaky/listener.rb
+++ b/lib/rspec_flaky/listener.rb
@@ -1,5 +1,11 @@
require 'json'
+require_relative 'config'
+require_relative 'example'
+require_relative 'flaky_example'
+require_relative 'flaky_examples_collection'
+require_relative 'report'
+
module RspecFlaky
class Listener
# - suite_flaky_examples: contains all the currently tracked flacky example
@@ -9,7 +15,7 @@ module RspecFlaky
attr_reader :suite_flaky_examples, :flaky_examples
def initialize(suite_flaky_examples_json = nil)
- @flaky_examples = FlakyExamplesCollection.new
+ @flaky_examples = RspecFlaky::FlakyExamplesCollection.new
@suite_flaky_examples = init_suite_flaky_examples(suite_flaky_examples_json)
end
@@ -18,47 +24,36 @@ module RspecFlaky
return unless current_example.attempts > 1
- flaky_example = suite_flaky_examples.fetch(current_example.uid) { FlakyExample.new(current_example) }
+ flaky_example = suite_flaky_examples.fetch(current_example.uid) { RspecFlaky::FlakyExample.new(current_example) }
flaky_example.update_flakiness!(last_attempts_count: current_example.attempts)
flaky_examples[current_example.uid] = flaky_example
end
def dump_summary(_)
- write_report_file(flaky_examples, RspecFlaky::Config.flaky_examples_report_path)
+ RspecFlaky::Report.new(flaky_examples).write(RspecFlaky::Config.flaky_examples_report_path)
+ # write_report_file(flaky_examples, RspecFlaky::Config.flaky_examples_report_path)
new_flaky_examples = flaky_examples - suite_flaky_examples
if new_flaky_examples.any?
Rails.logger.warn "\nNew flaky examples detected:\n"
- Rails.logger.warn JSON.pretty_generate(new_flaky_examples.to_report)
+ Rails.logger.warn JSON.pretty_generate(new_flaky_examples.to_h)
- write_report_file(new_flaky_examples, RspecFlaky::Config.new_flaky_examples_report_path)
+ RspecFlaky::Report.new(new_flaky_examples).write(RspecFlaky::Config.new_flaky_examples_report_path)
+ # write_report_file(new_flaky_examples, RspecFlaky::Config.new_flaky_examples_report_path)
end
end
- def to_report(examples)
- Hash[examples.map { |k, ex| [k, ex.to_h] }]
- end
-
private
def init_suite_flaky_examples(suite_flaky_examples_json = nil)
- unless suite_flaky_examples_json
+ if suite_flaky_examples_json
+ RspecFlaky::Report.load_json(suite_flaky_examples_json).flaky_examples
+ else
return {} unless File.exist?(RspecFlaky::Config.suite_flaky_examples_report_path)
- suite_flaky_examples_json = File.read(RspecFlaky::Config.suite_flaky_examples_report_path)
+ RspecFlaky::Report.load(RspecFlaky::Config.suite_flaky_examples_report_path).flaky_examples
end
-
- FlakyExamplesCollection.from_json(suite_flaky_examples_json)
- end
-
- def write_report_file(examples_collection, file_path)
- return unless RspecFlaky::Config.generate_report?
-
- report_path_dir = File.dirname(file_path)
- FileUtils.mkdir_p(report_path_dir) unless Dir.exist?(report_path_dir)
-
- File.write(file_path, JSON.pretty_generate(examples_collection.to_report))
end
end
end
diff --git a/lib/rspec_flaky/report.rb b/lib/rspec_flaky/report.rb
new file mode 100644
index 00000000000..a8730d3b7c7
--- /dev/null
+++ b/lib/rspec_flaky/report.rb
@@ -0,0 +1,54 @@
+require 'json'
+require 'time'
+
+require_relative 'config'
+require_relative 'flaky_examples_collection'
+
+module RspecFlaky
+ # This class is responsible for loading/saving JSON reports, and pruning
+ # outdated examples.
+ class Report < SimpleDelegator
+ OUTDATED_DAYS_THRESHOLD = 90
+
+ attr_reader :flaky_examples
+
+ def self.load(file_path)
+ load_json(File.read(file_path))
+ end
+
+ def self.load_json(json)
+ new(RspecFlaky::FlakyExamplesCollection.new(JSON.parse(json)))
+ end
+
+ def initialize(flaky_examples)
+ unless flaky_examples.is_a?(RspecFlaky::FlakyExamplesCollection)
+ raise ArgumentError, "`flaky_examples` must be a RspecFlaky::FlakyExamplesCollection, #{flaky_examples.class} given!"
+ end
+
+ @flaky_examples = flaky_examples
+ super(flaky_examples)
+ end
+
+ def write(file_path)
+ unless RspecFlaky::Config.generate_report?
+ puts "! Generating reports is disabled. To enable it, please set the `FLAKY_RSPEC_GENERATE_REPORT=1` !" # rubocop:disable Rails/Output
+ return
+ end
+
+ report_path_dir = File.dirname(file_path)
+ FileUtils.mkdir_p(report_path_dir) unless Dir.exist?(report_path_dir)
+
+ File.write(file_path, JSON.pretty_generate(flaky_examples.to_h))
+ end
+
+ def prune_outdated(days: OUTDATED_DAYS_THRESHOLD)
+ outdated_date_threshold = Time.now - (3600 * 24 * days)
+ updated_hash = flaky_examples.dup
+ .delete_if do |uid, hash|
+ hash[:last_flaky_at] && Time.parse(hash[:last_flaky_at]).to_i < outdated_date_threshold.to_i
+ end
+
+ self.class.new(RspecFlaky::FlakyExamplesCollection.new(updated_hash))
+ end
+ end
+end
diff --git a/package.json b/package.json
index fcfa4efa991..f6907e1fd16 100644
--- a/package.json
+++ b/package.json
@@ -5,8 +5,8 @@
"eslint": "eslint --max-warnings 0 --ext .js,.vue .",
"eslint-fix": "eslint --max-warnings 0 --ext .js,.vue --fix .",
"eslint-report": "eslint --max-warnings 0 --ext .js,.vue --format html --output-file ./eslint-report.html .",
- "karma": "karma start config/karma.config.js --single-run",
- "karma-coverage": "BABEL_ENV=coverage karma start config/karma.config.js --single-run",
+ "karma": "karma start --single-run true config/karma.config.js",
+ "karma-coverage": "BABEL_ENV=coverage karma start --single-run true config/karma.config.js",
"karma-start": "karma start config/karma.config.js",
"prettier-staged": "node ./scripts/frontend/prettier.js",
"prettier-staged-save": "node ./scripts/frontend/prettier.js save",
@@ -99,6 +99,7 @@
"axios-mock-adapter": "^1.10.0",
"babel-eslint": "^8.0.2",
"babel-plugin-istanbul": "^4.1.5",
+ "commander": "^2.15.1",
"eslint": "^3.18.0",
"eslint-config-airbnb-base": "^10.0.1",
"eslint-import-resolver-webpack": "^0.8.3",
diff --git a/scripts/prune-old-flaky-specs b/scripts/prune-old-flaky-specs
new file mode 100755
index 00000000000..f7451fbd428
--- /dev/null
+++ b/scripts/prune-old-flaky-specs
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+
+# lib/rspec_flaky/flaky_examples_collection.rb is requiring
+# `active_support/hash_with_indifferent_access`, and we install the `activesupport`
+# gem manually on the CI
+require 'rubygems'
+
+require_relative '../lib/rspec_flaky/report'
+
+report_file = ARGV.shift
+unless report_file
+ puts 'usage: prune-old-flaky-specs <report-file> <new-report-file>'
+ exit 1
+end
+
+new_report_file = ARGV.shift || report_file
+report = RspecFlaky::Report.load(report_file)
+puts "Loading #{report_file}..."
+puts "Current report has #{report.size} entries."
+
+new_report = report.prune_outdated
+
+puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than 90 days were removed."
+puts "Saved #{new_report_file}." if new_report.write(new_report_file)
diff --git a/spec/controllers/concerns/checks_collaboration_spec.rb b/spec/controllers/concerns/checks_collaboration_spec.rb
new file mode 100644
index 00000000000..1bd764290ae
--- /dev/null
+++ b/spec/controllers/concerns/checks_collaboration_spec.rb
@@ -0,0 +1,55 @@
+require 'spec_helper'
+
+describe ChecksCollaboration do
+ include ProjectForksHelper
+
+ let(:helper) do
+ fake_class = Class.new(ApplicationController) do
+ include ChecksCollaboration
+ end
+
+ fake_class.new
+ end
+
+ describe '#can_collaborate_with_project?' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :public) }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ allow(helper).to receive(:can?) do |user, ability, subject|
+ Ability.allowed?(user, ability, subject)
+ end
+ end
+
+ it 'is true if the user can push to the project' do
+ project.add_developer(user)
+
+ expect(helper.can_collaborate_with_project?(project)).to be_truthy
+ end
+
+ it 'is true when the user can push to a branch of the project' do
+ fake_access = double('Gitlab::UserAccess')
+ expect(fake_access).to receive(:can_push_to_branch?).with('a-branch').and_return(true)
+ expect(Gitlab::UserAccess).to receive(:new).with(user, project: project).and_return(fake_access)
+
+ expect(helper.can_collaborate_with_project?(project, ref: 'a-branch')).to be_truthy
+ end
+
+ context 'when the user has forked the project' do
+ before do
+ fork_project(project, user, namespace: user.namespace)
+ end
+
+ it 'is true' do
+ expect(helper.can_collaborate_with_project?(project)).to be_truthy
+ end
+
+ it 'is false when the project is archived' do
+ project.archived = true
+
+ expect(helper.can_collaborate_with_project?(project)).to be_falsy
+ end
+ end
+ end
+end
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index 01b5506b64b..ca86b0bc737 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -938,7 +938,7 @@ describe Projects::IssuesController do
end
describe 'POST create_merge_request' do
- let(:project) { create(:project, :repository) }
+ let(:project) { create(:project, :repository, :public) }
before do
project.add_developer(user)
@@ -955,6 +955,22 @@ describe Projects::IssuesController do
expect(response).to match_response_schema('merge_request')
end
+ it 'is not available when the project is archived' do
+ project.update!(archived: true)
+
+ create_merge_request
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+
+ it 'is not available for users who cannot create merge requests' do
+ sign_in(create(:user))
+
+ create_merge_request
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+
def create_merge_request
post :create_merge_request, namespace_id: project.namespace.to_param,
project_id: project.to_param,
diff --git a/spec/factories/award_emoji.rb b/spec/factories/award_emoji.rb
index a0abbbce686..d37e2bf511e 100644
--- a/spec/factories/award_emoji.rb
+++ b/spec/factories/award_emoji.rb
@@ -4,6 +4,10 @@ FactoryBot.define do
user
awardable factory: :issue
+ after(:create) do |award, evaluator|
+ award.awardable.project.add_guest(evaluator.user)
+ end
+
trait :upvote
trait :downvote do
name "thumbsdown"
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index fdacbe6c3f1..bca7e920de4 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -62,7 +62,6 @@ FactoryBot.define do
end
trait :pending do
- queued_at 'Di 29. Okt 09:50:59 CET 2013'
status 'pending'
end
diff --git a/spec/features/admin/admin_broadcast_messages_spec.rb b/spec/features/admin/admin_broadcast_messages_spec.rb
index 9cb351282a0..430a8d22b0f 100644
--- a/spec/features/admin/admin_broadcast_messages_spec.rb
+++ b/spec/features/admin/admin_broadcast_messages_spec.rb
@@ -45,7 +45,7 @@ feature 'Admin Broadcast Messages' do
page.within('.broadcast-message-preview') do
expect(page).to have_selector('strong', text: 'Markdown')
- expect(page).to have_selector('gl-emoji[data-name="tada"]')
+ expect(page).to have_emoji('tada')
end
end
end
diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb
index 986f864f0b5..257a3822503 100644
--- a/spec/features/dashboard/projects_spec.rb
+++ b/spec/features/dashboard/projects_spec.rb
@@ -89,7 +89,7 @@ feature 'Dashboard Projects' do
end
describe 'with a pipeline', :clean_gitlab_redis_shared_state do
- let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha) }
+ let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch) }
before do
# Since the cache isn't updated when a new pipeline is created
@@ -102,7 +102,7 @@ feature 'Dashboard Projects' do
visit dashboard_projects_path
page.within('.controls') do
- expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit)}']")
+ expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']")
expect(page).to have_css('.ci-status-link')
expect(page).to have_css('.ci-status-icon-success')
expect(page).to have_link('Commit: passed')
diff --git a/spec/features/groups/show_spec.rb b/spec/features/groups/show_spec.rb
index 4ffadbbcd35..3a0424d60f8 100644
--- a/spec/features/groups/show_spec.rb
+++ b/spec/features/groups/show_spec.rb
@@ -98,7 +98,7 @@ feature 'Group show page' do
it 'shows the project info' do
expect(page).to have_content(project.title)
- expect(page).to have_selector('gl-emoji[data-name="smile"]')
+ expect(page).to have_emoji('smile')
end
end
end
diff --git a/spec/features/merge_request/user_awards_emoji_spec.rb b/spec/features/merge_request/user_awards_emoji_spec.rb
index 2f24cfbd9e3..859a4c65562 100644
--- a/spec/features/merge_request/user_awards_emoji_spec.rb
+++ b/spec/features/merge_request/user_awards_emoji_spec.rb
@@ -35,6 +35,14 @@ describe 'Merge request > User awards emoji', :js do
expect(page).to have_selector('.emoji-menu', count: 1)
end
+
+ describe 'the project is archived' do
+ let(:project) { create(:project, :public, :repository, :archived) }
+
+ it 'does not see award menu button' do
+ expect(page).not_to have_selector('.js-award-holder')
+ end
+ end
end
describe 'logged out' do
diff --git a/spec/features/merge_request/user_cherry_picks_spec.rb b/spec/features/merge_request/user_cherry_picks_spec.rb
index 494096b21c0..61d1bdaa95a 100644
--- a/spec/features/merge_request/user_cherry_picks_spec.rb
+++ b/spec/features/merge_request/user_cherry_picks_spec.rb
@@ -40,6 +40,14 @@ describe 'Merge request > User cherry-picks', :js do
expect(page).to have_link 'Cherry-pick'
end
+
+ it 'hides the cherry pick button for an archived project' do
+ project.update!(archived: true)
+
+ visit project_merge_request_path(project, merge_request)
+
+ expect(page).not_to have_link 'Cherry-pick'
+ end
end
end
end
diff --git a/spec/features/milestones/show_spec.rb b/spec/features/milestones/show_spec.rb
deleted file mode 100644
index 50c5e0bb65f..00000000000
--- a/spec/features/milestones/show_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'rails_helper'
-
-describe 'Milestone show' do
- let(:user) { create(:user) }
- let(:project) { create(:project) }
- let(:milestone) { create(:milestone, project: project) }
- let(:labels) { create_list(:label, 2, project: project) }
- let(:issue_params) { { project: project, assignees: [user], author: user, milestone: milestone, labels: labels } }
-
- before do
- project.add_user(user, :developer)
- sign_in(user)
- end
-
- def visit_milestone
- visit project_milestone_path(project, milestone)
- end
-
- it 'avoids N+1 database queries' do
- create(:labeled_issue, issue_params)
- control = ActiveRecord::QueryRecorder.new { visit_milestone }
- create_list(:labeled_issue, 10, issue_params)
-
- expect { visit_milestone }.not_to exceed_query_limit(control)
- end
-end
diff --git a/spec/features/milestones/user_creates_milestone_spec.rb b/spec/features/milestones/user_creates_milestone_spec.rb
new file mode 100644
index 00000000000..8fd057d587c
--- /dev/null
+++ b/spec/features/milestones/user_creates_milestone_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+describe "User creates milestone", :js do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(new_project_milestone_path(project))
+ end
+
+ it "creates milestone" do
+ TITLE = "v2.3".freeze
+
+ fill_in("Title", with: TITLE)
+ fill_in("Description", with: "# Description header")
+ click_button("Create milestone")
+
+ expect(page).to have_content(TITLE)
+ .and have_content("Issues")
+ .and have_header_with_correct_id_and_link(1, "Description header", "description-header")
+
+ visit(activity_project_path(project))
+
+ expect(page).to have_content("#{user.name} opened milestone")
+ end
+end
diff --git a/spec/features/milestones/user_deletes_milestone_spec.rb b/spec/features/milestones/user_deletes_milestone_spec.rb
new file mode 100644
index 00000000000..414702daba4
--- /dev/null
+++ b/spec/features/milestones/user_deletes_milestone_spec.rb
@@ -0,0 +1,25 @@
+require "rails_helper"
+
+describe "User deletes milestone", :js do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+ set(:milestone) { create(:milestone, project: project) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(project_milestones_path(project))
+ end
+
+ it "deletes milestone" do
+ click_button("Delete")
+ click_button("Delete milestone")
+
+ expect(page).to have_content("No milestones to show")
+
+ visit(activity_project_path(project))
+
+ expect(page).to have_content("#{user.name} destroyed milestone")
+ end
+end
diff --git a/spec/features/milestones/user_views_milestone_spec.rb b/spec/features/milestones/user_views_milestone_spec.rb
new file mode 100644
index 00000000000..83d8e2ff9e9
--- /dev/null
+++ b/spec/features/milestones/user_views_milestone_spec.rb
@@ -0,0 +1,31 @@
+require "rails_helper"
+
+describe "User views milestone" do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+ set(:milestone) { create(:milestone, project: project) }
+ set(:labels) { create_list(:label, 2, project: project) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+ end
+
+ it "avoids N+1 database queries" do
+ ISSUE_PARAMS = { project: project, assignees: [user], author: user, milestone: milestone, labels: labels }.freeze
+
+ create(:labeled_issue, ISSUE_PARAMS)
+
+ control = ActiveRecord::QueryRecorder.new { visit_milestone }
+
+ create(:labeled_issue, ISSUE_PARAMS)
+
+ expect { visit_milestone }.not_to exceed_query_limit(control)
+ end
+
+ private
+
+ def visit_milestone
+ visit(project_milestone_path(project, milestone))
+ end
+end
diff --git a/spec/features/milestones/user_views_milestones_spec.rb b/spec/features/milestones/user_views_milestones_spec.rb
new file mode 100644
index 00000000000..bebe40f73fd
--- /dev/null
+++ b/spec/features/milestones/user_views_milestones_spec.rb
@@ -0,0 +1,35 @@
+require "rails_helper"
+
+describe "User views milestones" do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+ set(:milestone) { create(:milestone, project: project) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(project_milestones_path(project))
+ end
+
+ it "shows milestone" do
+ expect(page).to have_content(milestone.title)
+ .and have_content(milestone.expires_at)
+ .and have_content("Issues")
+ end
+
+ context "with issues" do
+ set(:issue) { create(:issue, project: project, milestone: milestone) }
+ set(:closed_issue) { create(:closed_issue, project: project, milestone: milestone) }
+
+ it "opens milestone" do
+ click_link(milestone.title)
+
+ expect(current_path).to eq(project_milestone_path(project, milestone))
+ expect(page).to have_content(milestone.title)
+ .and have_selector("#tab-issues li.issuable-row", count: 2)
+ .and have_content(issue.title)
+ .and have_content(closed_issue.title)
+ end
+ end
+end
diff --git a/spec/features/projects/activity/rss_spec.rb b/spec/features/projects/activity/rss_spec.rb
index 2693e539268..cd1cfe07998 100644
--- a/spec/features/projects/activity/rss_spec.rb
+++ b/spec/features/projects/activity/rss_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
feature 'Project Activity RSS' do
- let(:user) { create(:user) }
- let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
+ let(:project) { create(:project, :public) }
+ let(:user) { project.owner }
let(:path) { activity_project_path(project) }
before do
@@ -11,8 +11,7 @@ feature 'Project Activity RSS' do
context 'when signed in' do
before do
- project.add_developer(user)
- sign_in(user)
+ sign_in(project.owner)
visit path
end
diff --git a/spec/features/projects/activity/user_sees_activity_spec.rb b/spec/features/projects/activity/user_sees_activity_spec.rb
new file mode 100644
index 00000000000..644a837dc14
--- /dev/null
+++ b/spec/features/projects/activity/user_sees_activity_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+feature 'Projects > Activity > User sees activity' do
+ let(:project) { create(:project, :repository, :public) }
+ let(:user) { project.creator }
+
+ before do
+ event = create(:push_event, project: project, author: user)
+ create(:push_event_payload,
+ event: event,
+ action: :created,
+ commit_to: '6d394385cf567f80a8fd85055db1ab4c5295806f',
+ ref: 'fix',
+ commit_count: 1)
+ visit activity_project_path(project)
+ end
+
+ it 'shows the last push in the activity page', :js do
+ expect(page).to have_content "#{user.name} pushed new branch fix"
+ end
+end
diff --git a/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb b/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb
index adff0a10f0e..12e07647ecd 100644
--- a/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb
+++ b/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb
@@ -99,6 +99,74 @@ describe 'User interacts with awards in an issue', :js do
click_button('Comment')
end
- expect(page).to have_selector('gl-emoji[data-name="smile"]')
+ expect(page).to have_emoji('smile')
+ end
+
+ context 'when a project is archived' do
+ let(:project) { create(:project, :archived) }
+
+ it 'hides the add award button' do
+ page.within('.awards') do
+ expect(page).not_to have_css('.js-add-award')
+ end
+ end
+ end
+
+ context 'awards on a note' do
+ let!(:note) { create(:note, noteable: issue, project: issue.project) }
+ let!(:award_emoji) { create(:award_emoji, awardable: note, name: '100') }
+
+ it 'shows the award on the note' do
+ page.within('.note-awards') do
+ expect(page).to have_emoji('100')
+ end
+ end
+
+ it 'allows adding a vote to an award' do
+ page.within('.note-awards') do
+ find('gl-emoji[data-name="100"]').click
+ end
+ wait_for_requests
+
+ expect(note.reload.award_emoji.size).to eq(2)
+ end
+
+ it 'allows adding a new emoji' do
+ page.within('.note-actions') do
+ find('a.js-add-award').click
+ end
+ page.within('.emoji-menu-content') do
+ find('gl-emoji[data-name="8ball"]').click
+ end
+ wait_for_requests
+
+ page.within('.note-awards') do
+ expect(page).to have_emoji('8ball')
+ end
+ expect(note.reload.award_emoji.size).to eq(2)
+ end
+
+ context 'when the project is archived' do
+ let(:project) { create(:project, :archived) }
+
+ it 'hides the buttons for adding new emoji' do
+ page.within('.note-awards') do
+ expect(page).not_to have_css('.award-menu-holder')
+ end
+
+ page.within('.note-actions') do
+ expect(page).not_to have_css('a.js-add-award')
+ end
+ end
+
+ it 'does not allow toggling existing emoji' do
+ page.within('.note-awards') do
+ find('gl-emoji[data-name="100"]').click
+ end
+ wait_for_requests
+
+ expect(note.reload.award_emoji.size).to eq(1)
+ end
+ end
end
end
diff --git a/spec/features/projects/branches/user_creates_branch_spec.rb b/spec/features/projects/branches/user_creates_branch_spec.rb
new file mode 100644
index 00000000000..b706ad64954
--- /dev/null
+++ b/spec/features/projects/branches/user_creates_branch_spec.rb
@@ -0,0 +1,46 @@
+require "spec_helper"
+
+describe "User creates branch", :js do
+ include Spec::Support::Helpers::Features::BranchesHelpers
+
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :repository) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(new_project_branch_path(project))
+ end
+
+ it "creates new branch" do
+ BRANCH_NAME = "deploy_keys".freeze
+
+ create_branch(BRANCH_NAME)
+
+ expect(page).to have_content(BRANCH_NAME)
+ end
+
+ context "when branch name is invalid" do
+ it "does not create new branch" do
+ INVALID_BRANCH_NAME = "1.0 stable".freeze
+
+ fill_in("branch_name", with: INVALID_BRANCH_NAME)
+ page.find("body").click # defocus the branch_name input
+
+ select_branch("master")
+ click_button("Create branch")
+
+ expect(page).to have_content("Branch name is invalid")
+ expect(page).to have_content("can't contain spaces")
+ end
+ end
+
+ context "when branch name already exists" do
+ it "does not create new branch" do
+ create_branch("master")
+
+ expect(page).to have_content("Branch already exists")
+ end
+ end
+end
diff --git a/spec/features/projects/branches/user_deletes_branch_spec.rb b/spec/features/projects/branches/user_deletes_branch_spec.rb
new file mode 100644
index 00000000000..96f215e1606
--- /dev/null
+++ b/spec/features/projects/branches/user_deletes_branch_spec.rb
@@ -0,0 +1,23 @@
+require "spec_helper"
+
+describe "User deletes branch", :js do
+ set(:user) { create(:user) }
+ set(:project) { create(:project, :repository) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(project_branches_path(project))
+ end
+
+ it "deletes branch" do
+ fill_in("branch-search", with: "improve/awesome").native.send_keys(:enter)
+
+ page.within(".js-branch-improve\\/awesome") do
+ accept_alert { find(".btn-remove").click }
+ end
+
+ expect(page).to have_css(".js-branch-improve\\/awesome", visible: :hidden)
+ end
+end
diff --git a/spec/features/projects/branches/user_views_branches_spec.rb b/spec/features/projects/branches/user_views_branches_spec.rb
new file mode 100644
index 00000000000..62ae793151c
--- /dev/null
+++ b/spec/features/projects/branches/user_views_branches_spec.rb
@@ -0,0 +1,34 @@
+require "spec_helper"
+
+describe "User views branches" do
+ set(:project) { create(:project, :repository) }
+ set(:user) { project.owner }
+
+ before do
+ sign_in(user)
+ end
+
+ context "all branches" do
+ before do
+ visit(project_branches_path(project))
+ end
+
+ it "shows branches" do
+ expect(page).to have_content("Branches").and have_content("master")
+ end
+ end
+
+ context "protected branches" do
+ set(:protected_branch) { create(:protected_branch, project: project) }
+
+ before do
+ visit(project_protected_branches_path(project))
+ end
+
+ it "shows branches" do
+ page.within(".protected-branches-list") do
+ expect(page).to have_content(protected_branch.name).and have_no_content("master")
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb
index 2a9d9e6416c..b7ce1b9993a 100644
--- a/spec/features/projects/branches_spec.rb
+++ b/spec/features/projects/branches_spec.rb
@@ -195,6 +195,26 @@ describe 'Branches' do
expect(page).to have_content("Protected branches can be managed in project settings")
end
end
+
+ it 'shows the merge request button' do
+ visit project_branches_path(project)
+
+ page.within first('.all-branches li') do
+ expect(page).to have_content 'Merge request'
+ end
+ end
+
+ context 'when the project is archived' do
+ let(:project) { create(:project, :public, :repository, :archived) }
+
+ it 'does not show the merge request button when the project is archived' do
+ visit project_branches_path(project)
+
+ page.within first('.all-branches li') do
+ expect(page).not_to have_content 'Merge request'
+ end
+ end
+ end
end
context 'logged out' do
@@ -204,7 +224,7 @@ describe 'Branches' do
it 'does not show merge request button' do
page.within first('.all-branches li') do
- expect(page).not_to have_content 'Merge Request'
+ expect(page).not_to have_content 'Merge request'
end
end
end
diff --git a/spec/features/projects/commit/cherry_pick_spec.rb b/spec/features/projects/commit/cherry_pick_spec.rb
index c4c399e3058..1df45865d6f 100644
--- a/spec/features/projects/commit/cherry_pick_spec.rb
+++ b/spec/features/projects/commit/cherry_pick_spec.rb
@@ -89,4 +89,15 @@ describe 'Cherry-pick Commits' do
expect(page).to have_content('The commit has been successfully cherry-picked.')
end
end
+
+ context 'when the project is archived' do
+ let(:project) { create(:project, :repository, :archived, namespace: group) }
+
+ it 'does not show the cherry-pick link' do
+ find('.header-action-buttons a.dropdown-toggle').click
+
+ expect(page).not_to have_text("Cherry-pick")
+ expect(page).not_to have_css("a[href='#modal-cherry-pick-commit']")
+ end
+ end
end
diff --git a/spec/features/projects/commit/user_reverts_commit_spec.rb b/spec/features/projects/commit/user_reverts_commit_spec.rb
index 221f1d7757e..42844a03ea6 100644
--- a/spec/features/projects/commit/user_reverts_commit_spec.rb
+++ b/spec/features/projects/commit/user_reverts_commit_spec.rb
@@ -10,13 +10,16 @@ describe 'User reverts a commit', :js do
sign_in(user)
visit(project_commit_path(project, sample_commit.id))
+ end
+ def click_revert
find('.header-action-buttons .dropdown').click
find('a[href="#modal-revert-commit"]').click
end
context 'without creating a new merge request' do
before do
+ click_revert
page.within('#modal-revert-commit') do
uncheck('create_merge_request')
click_button('Revert')
@@ -44,6 +47,10 @@ describe 'User reverts a commit', :js do
end
context 'with creating a new merge request' do
+ before do
+ click_revert
+ end
+
it 'reverts a commit' do
page.within('#modal-revert-commit') do
click_button('Revert')
@@ -53,4 +60,14 @@ describe 'User reverts a commit', :js do
expect(page).to have_content("From revert-#{Commit.truncate_sha(sample_commit.id)} into master")
end
end
+
+ context 'when the project is archived' do
+ let(:project) { create(:project, :repository, :archived, namespace: user.namespace) }
+
+ it 'does not show the revert link' do
+ find('.header-action-buttons .dropdown').click
+
+ expect(page).not_to have_link('Revert')
+ end
+ end
end
diff --git a/spec/features/projects/edit_spec.rb b/spec/features/projects/edit_spec.rb
deleted file mode 100644
index 1d4b4d0fdca..00000000000
--- a/spec/features/projects/edit_spec.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'rails_helper'
-
-feature 'Project edit', :js do
- let(:admin) { create(:admin) }
- let(:user) { create(:user) }
- let(:project) { create(:project) }
-
- context 'feature visibility' do
- before do
- project.add_master(user)
- sign_in(user)
-
- visit edit_project_path(project)
- end
-
- context 'merge requests select' do
- it 'hides merge requests section' do
- find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
-
- expect(page).to have_selector('.merge-requests-feature', visible: false)
- end
-
- context 'given project with merge_requests_disabled access level' do
- let(:project) { create(:project, :merge_requests_disabled) }
-
- it 'hides merge requests section' do
- expect(page).to have_selector('.merge-requests-feature', visible: false)
- end
- end
- end
-
- context 'builds select' do
- it 'hides builds select section' do
- find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
-
- expect(page).to have_selector('.builds-feature', visible: false)
- end
-
- context 'given project with builds_disabled access level' do
- let(:project) { create(:project, :builds_disabled) }
-
- it 'hides builds select section' do
- expect(page).to have_selector('.builds-feature', visible: false)
- end
- end
- end
- end
-
- context 'LFS enabled setting' do
- before do
- sign_in(admin)
- end
-
- it 'displays the correct elements' do
- allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
- visit edit_project_path(project)
-
- expect(page).to have_content('Git Large File Storage')
- expect(page).to have_selector('input[name="project[lfs_enabled]"] + button', visible: true)
- end
- end
-end
diff --git a/spec/features/projects/files/browse_files_spec.rb b/spec/features/projects/files/browse_files_spec.rb
deleted file mode 100644
index 2c38c380d9d..00000000000
--- a/spec/features/projects/files/browse_files_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require 'spec_helper'
-
-feature 'user browses project', :js do
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
-
- before do
- project.add_master(user)
- sign_in(user)
- visit project_tree_path(project, project.default_branch)
- end
-
- scenario "can see blame of '.gitignore'" do
- click_link ".gitignore"
- click_link 'Blame'
-
- expect(page).to have_content "*.rb"
- expect(page).to have_content "Dmitriy Zaporozhets"
- expect(page).to have_content "Initial commit"
- end
-
- scenario 'can see raw content of LFS pointer with LFS disabled' do
- allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false)
- click_link 'files'
- click_link 'lfs'
- click_link 'lfs_object.iso'
- wait_for_requests
-
- expect(page).not_to have_content 'Download (1.5 MB)'
- expect(page).to have_content 'version https://git-lfs.github.com/spec/v1'
- expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
- expect(page).to have_content 'size 1575078'
- end
-
- scenario 'can see last commit for current directory' do
- last_commit = project.repository.last_commit_for_path(project.default_branch, 'files')
-
- click_link 'files'
- wait_for_requests
-
- page.within('.blob-commit-info') do
- expect(page).to have_content last_commit.short_id
- expect(page).to have_content last_commit.author_name
- end
- end
-end
diff --git a/spec/features/projects/files/creating_a_file_spec.rb b/spec/features/projects/files/creating_a_file_spec.rb
deleted file mode 100644
index 8d982636525..00000000000
--- a/spec/features/projects/files/creating_a_file_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require 'spec_helper'
-
-feature 'User wants to create a file' do
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
-
- background do
- project.add_master(user)
- sign_in user
- visit project_new_blob_path(project, project.default_branch)
- end
-
- def submit_new_file(options)
- file_name = find('#file_name')
- file_name.set options[:file_name] || 'README.md'
-
- file_content = find('#file-content', visible: false)
- file_content.set options[:file_content] || 'Some content'
-
- click_button 'Commit changes'
- end
-
- scenario 'file name contains Chinese characters' do
- submit_new_file(file_name: '测试.md')
- expect(page).to have_content 'The file has been successfully created.'
- end
-
- scenario 'directory name contains Chinese characters' do
- submit_new_file(file_name: '中文/测试.md')
- expect(page).to have_content 'The file has been successfully created'
- end
-
- scenario 'file name contains directory traversal' do
- submit_new_file(file_name: '../README.md')
- expect(page).to have_content 'Path cannot include directory traversal'
- end
-end
diff --git a/spec/features/projects/files/dockerfile_dropdown_spec.rb b/spec/features/projects/files/dockerfile_dropdown_spec.rb
index f4a39e331fd..004585f7c9e 100644
--- a/spec/features/projects/files/dockerfile_dropdown_spec.rb
+++ b/spec/features/projects/files/dockerfile_dropdown_spec.rb
@@ -1,22 +1,15 @@
require 'spec_helper'
-require 'fileutils'
-feature 'User wants to add a Dockerfile file' do
+describe 'Projects > Files > User wants to add a Dockerfile file' do
before do
- user = create(:user)
project = create(:project, :repository)
- project.add_master(user)
-
- sign_in user
-
+ sign_in project.owner
visit project_new_blob_path(project, 'master', file_name: 'Dockerfile')
end
- scenario 'user can see Dockerfile dropdown' do
+ it 'user can pick a Dockerfile file from the dropdown', :js do
expect(page).to have_css('.dockerfile-selector')
- end
- scenario 'user can pick a Dockerfile file from the dropdown', :js do
find('.js-dockerfile-selector').click
wait_for_requests
diff --git a/spec/features/projects/files/download_buttons_spec.rb b/spec/features/projects/files/download_buttons_spec.rb
index 2101627f324..03cb3530e2b 100644
--- a/spec/features/projects/files/download_buttons_spec.rb
+++ b/spec/features/projects/files/download_buttons_spec.rb
@@ -1,42 +1,36 @@
require 'spec_helper'
-feature 'Download buttons in files tree' do
- given(:user) { create(:user) }
- given(:role) { :developer }
- given(:status) { 'success' }
- given(:project) { create(:project, :repository) }
+describe 'Projects > Files > Download buttons in files tree' do
+ let(:project) { create(:project, :repository) }
+ let(:user) { project.creator }
- given(:pipeline) do
+ let(:pipeline) do
create(:ci_pipeline,
project: project,
sha: project.commit.sha,
ref: project.default_branch,
- status: status)
+ status: 'success')
end
- given!(:build) do
+ let!(:build) do
create(:ci_build, :success, :artifacts,
pipeline: pipeline,
status: pipeline.status,
name: 'build')
end
- background do
+ before do
sign_in(user)
- project.add_role(user, role)
- end
+ project.add_developer(user)
- describe 'when files tree' do
- context 'with artifacts' do
- before do
- visit project_tree_path(project, project.default_branch)
- end
+ visit project_tree_path(project, project.default_branch)
+ end
- scenario 'shows download artifacts button' do
- href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
+ context 'with artifacts' do
+ it 'shows download artifacts button' do
+ href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
- expect(page).to have_link "Download '#{build.name}'", href: href
- end
+ expect(page).to have_link "Download '#{build.name}'", href: href
end
end
end
diff --git a/spec/features/projects/files/edit_file_soft_wrap_spec.rb b/spec/features/projects/files/edit_file_soft_wrap_spec.rb
index 8d32ada5795..41af70d8ebc 100644
--- a/spec/features/projects/files/edit_file_soft_wrap_spec.rb
+++ b/spec/features/projects/files/edit_file_soft_wrap_spec.rb
@@ -1,10 +1,9 @@
require 'spec_helper'
-feature 'User uses soft wrap whilst editing file', :js do
+describe 'Projects > Files > User uses soft wrap whilst editing file', :js do
before do
- user = create(:user)
project = create(:project, :repository)
- project.add_master(user)
+ user = project.owner
sign_in user
visit project_new_blob_path(project, 'master', file_name: 'test_file-name')
page.within('.file-editor.code') do
@@ -23,7 +22,7 @@ feature 'User uses soft wrap whilst editing file', :js do
let(:toggle_button) { find('.soft-wrap-toggle') }
- scenario 'user clicks the "Soft wrap" button and then "No wrap" button' do
+ it 'user clicks the "Soft wrap" button and then "No wrap" button' do
wrapped_content_width = get_content_width
toggle_button.click
expect(toggle_button).to have_content 'No wrap'
diff --git a/spec/features/projects/files/editing_a_file_spec.rb b/spec/features/projects/files/editing_a_file_spec.rb
index d874cdbff8d..4074e67e2d2 100644
--- a/spec/features/projects/files/editing_a_file_spec.rb
+++ b/spec/features/projects/files/editing_a_file_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
-feature 'User wants to edit a file' do
+describe 'Projects > Files > User wants to edit a file' do
let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
+ let(:user) { project.owner }
let(:commit_params) do
{
start_branch: project.default_branch,
@@ -15,14 +15,13 @@ feature 'User wants to edit a file' do
}
end
- background do
- project.add_master(user)
+ before do
sign_in user
visit project_edit_blob_path(project,
File.join(project.default_branch, '.gitignore'))
end
- scenario 'file has been updated since the user opened the edit page' do
+ it 'file has been updated since the user opened the edit page' do
Files::UpdateService.new(project, user, commit_params).execute
click_button 'Commit changes'
diff --git a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
index ead9f7e9168..b6dbf76bc9b 100644
--- a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
+++ b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
@@ -1,16 +1,15 @@
require 'spec_helper'
-feature 'User views files page' do
- let(:user) { create(:user) }
+describe 'Projects > Files > User views files page' do
let(:project) { create(:forked_project_with_submodules) }
+ let(:user) { project.owner }
before do
- project.add_master(user)
sign_in user
visit project_tree_path(project, project.repository.root_ref)
end
- scenario 'user sees folders and submodules sorted together, followed by files' do
+ it 'user sees folders and submodules sorted together, followed by files' do
rows = all('td.tree-item-file-name').map(&:text)
tree = project.repository.tree
diff --git a/spec/features/projects/files/find_file_keyboard_spec.rb b/spec/features/projects/files/find_file_keyboard_spec.rb
index e9ff06c72d8..cd0235f2b9e 100644
--- a/spec/features/projects/files/find_file_keyboard_spec.rb
+++ b/spec/features/projects/files/find_file_keyboard_spec.rb
@@ -1,11 +1,10 @@
require 'spec_helper'
-feature 'Find file keyboard shortcuts', :js do
- let(:user) { create(:user) }
+describe 'Projects > Files > Find file keyboard shortcuts', :js do
let(:project) { create(:project, :repository) }
+ let(:user) { project.owner }
before do
- project.add_master(user)
sign_in user
visit project_find_file_path(project, project.repository.root_ref)
diff --git a/spec/features/projects/files/gitignore_dropdown_spec.rb b/spec/features/projects/files/gitignore_dropdown_spec.rb
index 79f3fd09b48..9fa4c053a40 100644
--- a/spec/features/projects/files/gitignore_dropdown_spec.rb
+++ b/spec/features/projects/files/gitignore_dropdown_spec.rb
@@ -1,25 +1,24 @@
require 'spec_helper'
-feature 'User wants to add a .gitignore file' do
+describe 'Projects > Files > User wants to add a .gitignore file' do
before do
- user = create(:user)
project = create(:project, :repository)
- project.add_master(user)
- sign_in user
+ sign_in project.owner
visit project_new_blob_path(project, 'master', file_name: '.gitignore')
end
- scenario 'user can see .gitignore dropdown' do
+ it 'user can pick a .gitignore file from the dropdown', :js do
expect(page).to have_css('.gitignore-selector')
- end
- scenario 'user can pick a .gitignore file from the dropdown', :js do
find('.js-gitignore-selector').click
+
wait_for_requests
+
within '.gitignore-selector' do
find('.dropdown-input-field').set('rails')
find('.dropdown-content li', text: 'Rails').click
end
+
wait_for_requests
expect(page).to have_css('.gitignore-selector .dropdown-toggle-text', text: 'Rails')
diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb
index db6c67b802e..53aff183562 100644
--- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb
+++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb
@@ -1,25 +1,24 @@
require 'spec_helper'
-feature 'User wants to add a .gitlab-ci.yml file' do
+describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
before do
- user = create(:user)
project = create(:project, :repository)
- project.add_master(user)
- sign_in user
+ sign_in project.owner
visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml')
end
- scenario 'user can see .gitlab-ci.yml dropdown' do
+ it 'user can pick a template from the dropdown', :js do
expect(page).to have_css('.gitlab-ci-yml-selector')
- end
- scenario 'user can pick a template from the dropdown', :js do
find('.js-gitlab-ci-yml-selector').click
+
wait_for_requests
+
within '.gitlab-ci-yml-selector' do
find('.dropdown-input-field').set('Jekyll')
find('.dropdown-content li', text: 'Jekyll').click
end
+
wait_for_requests
expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Jekyll')
diff --git a/spec/features/projects/files/project_owner_creates_license_file_spec.rb b/spec/features/projects/files/project_owner_creates_license_file_spec.rb
index 07599600876..b410199fd1f 100644
--- a/spec/features/projects/files/project_owner_creates_license_file_spec.rb
+++ b/spec/features/projects/files/project_owner_creates_license_file_spec.rb
@@ -1,17 +1,17 @@
require 'spec_helper'
-feature 'project owner creates a license file', :js do
- let(:project_master) { create(:user) }
+describe 'Projects > Files > Project owner creates a license file', :js do
let(:project) { create(:project, :repository) }
- background do
+ let(:project_master) { project.owner }
+
+ before do
project.repository.delete_file(project_master, 'LICENSE',
message: 'Remove LICENSE', branch_name: 'master')
- project.add_master(project_master)
sign_in(project_master)
visit project_path(project)
end
- scenario 'project master creates a license file manually from a template' do
+ it 'project master creates a license file manually from a template' do
visit project_tree_path(project, project.repository.root_ref)
find('.add-to-tree').click
click_link 'New file'
@@ -35,7 +35,7 @@ feature 'project owner creates a license file', :js do
expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
end
- scenario 'project master creates a license file from the "Add license" link' do
+ it 'project master creates a license file from the "Add license" link' do
click_link 'Add License'
expect(page).to have_content('New file')
diff --git a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
index 7f1d1934103..53d8ace7c94 100644
--- a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
+++ b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
@@ -1,15 +1,14 @@
require 'spec_helper'
-feature 'project owner sees a link to create a license file in empty project', :js do
- let(:project_master) { create(:user) }
+describe 'Projects > Files > Project owner sees a link to create a license file in empty project', :js do
let(:project) { create(:project_empty_repo) }
+ let(:project_master) { project.owner }
- background do
- project.add_master(project_master)
+ before do
sign_in(project_master)
end
- scenario 'project master creates a license file from a template' do
+ it 'project master creates a license file from a template' do
visit project_path(project)
click_on 'Add License'
expect(page).to have_content('New file')
diff --git a/spec/features/projects/files/template_type_dropdown_spec.rb b/spec/features/projects/files/template_type_dropdown_spec.rb
index 97408a9c41e..342a93b328f 100644
--- a/spec/features/projects/files/template_type_dropdown_spec.rb
+++ b/spec/features/projects/files/template_type_dropdown_spec.rb
@@ -1,11 +1,10 @@
require 'spec_helper'
-feature 'Template type dropdown selector', :js do
+describe 'Projects > Files > Template type dropdown selector', :js do
let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
+ let(:user) { project.owner }
before do
- project.add_master(user)
sign_in user
end
@@ -14,16 +13,16 @@ feature 'Template type dropdown selector', :js do
create_and_edit_file('.random-file.js')
end
- scenario 'not displayed' do
+ it 'not displayed' do
check_type_selector_display(false)
end
- scenario 'selects every template type correctly' do
+ it 'selects every template type correctly' do
fill_in 'file_path', with: '.gitignore'
try_selecting_all_types
end
- scenario 'updates toggle value when input matches' do
+ it 'updates toggle value when input matches' do
fill_in 'file_path', with: '.gitignore'
check_type_selector_toggle_text('.gitignore')
end
@@ -34,15 +33,15 @@ feature 'Template type dropdown selector', :js do
visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE'))
end
- scenario 'displayed' do
+ it 'displayed' do
check_type_selector_display(true)
end
- scenario 'is displayed when input matches' do
+ it 'is displayed when input matches' do
check_type_selector_display(true)
end
- scenario 'selects every template type correctly' do
+ it 'selects every template type correctly' do
try_selecting_all_types
end
@@ -51,7 +50,7 @@ feature 'Template type dropdown selector', :js do
click_link 'Preview changes'
end
- scenario 'type selector is hidden and shown correctly' do
+ it 'type selector is hidden and shown correctly' do
check_type_selector_display(false)
click_link 'Write'
check_type_selector_display(true)
@@ -64,15 +63,15 @@ feature 'Template type dropdown selector', :js do
visit project_new_blob_path(project, 'master', file_name: '.gitignore')
end
- scenario 'is displayed' do
+ it 'is displayed' do
check_type_selector_display(true)
end
- scenario 'toggle is set to the correct value' do
+ it 'toggle is set to the correct value' do
check_type_selector_toggle_text('.gitignore')
end
- scenario 'selects every template type correctly' do
+ it 'selects every template type correctly' do
try_selecting_all_types
end
end
@@ -82,15 +81,15 @@ feature 'Template type dropdown selector', :js do
visit project_new_blob_path(project, project.default_branch)
end
- scenario 'type selector is shown' do
+ it 'type selector is shown' do
check_type_selector_display(true)
end
- scenario 'toggle is set to the proper value' do
+ it 'toggle is set to the proper value' do
check_type_selector_toggle_text('Choose type')
end
- scenario 'selects every template type correctly' do
+ it 'selects every template type correctly' do
try_selecting_all_types
end
end
diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb
index fbf35fb4e1c..5de0bc009fb 100644
--- a/spec/features/projects/files/undo_template_spec.rb
+++ b/spec/features/projects/files/undo_template_spec.rb
@@ -1,11 +1,10 @@
require 'spec_helper'
-feature 'Template Undo Button', :js do
+describe 'Projects > Files > Template Undo Button', :js do
let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
+ let(:user) { project.owner }
before do
- project.add_master(user)
sign_in user
end
@@ -15,7 +14,7 @@ feature 'Template Undo Button', :js do
select_file_template('.js-license-selector', 'Apache License 2.0')
end
- scenario 'reverts template application' do
+ it 'reverts template application' do
try_template_undo('http://www.apache.org/licenses/', 'Apply a license template')
end
end
@@ -27,7 +26,7 @@ feature 'Template Undo Button', :js do
select_file_template('.js-license-selector', 'Apache License 2.0')
end
- scenario 'reverts template application' do
+ it 'reverts template application' do
try_template_undo('http://www.apache.org/licenses/', 'Apply a license template')
end
end
diff --git a/spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
index a17e65cc5b9..2d67837763c 100644
--- a/spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
+++ b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
@@ -1,9 +1,9 @@
require 'spec_helper'
# This is a regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/37569
-describe 'User browses a tree with a folder containing only a folder' do
+describe 'Projects > Files > User browses a tree with a folder containing only a folder' do
let(:project) { create(:project, :empty_repo) }
- let(:user) { project.creator }
+ let(:user) { project.owner }
before do
# We need to disable the tree.flat_path provided by Gitaly to reproduce the issue
diff --git a/spec/features/projects/user_browses_files_spec.rb b/spec/features/projects/files/user_browses_files_spec.rb
index 62e6419cc42..9c1f11f4c12 100644
--- a/spec/features/projects/user_browses_files_spec.rb
+++ b/spec/features/projects/files/user_browses_files_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
-describe 'User browses files' do
- include DropzoneHelper
-
+describe 'Projects > Files > User browses files' do
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
@@ -12,13 +10,24 @@ describe 'User browses files' do
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:tree_path_ref_6d39438) { project_tree_path(project, '6d39438') }
let(:tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
- let(:user) { create(:user) }
+ let(:user) { project.owner }
before do
- project.add_master(user)
sign_in(user)
end
+ it 'shows last commit for current directory' do
+ visit(tree_path_root_ref)
+
+ click_link 'files'
+
+ last_commit = project.repository.last_commit_for_path(project.default_branch, 'files')
+ page.within('.blob-commit-info') do
+ expect(page).to have_content last_commit.short_id
+ expect(page).to have_content last_commit.author_name
+ end
+ end
+
context 'when browsing the master branch' do
before do
visit(tree_path_root_ref)
@@ -48,7 +57,7 @@ describe 'User browses files' do
expect(page).not_to have_link('Browse Files')
end
- it 'shows the "Browse Code" link' do
+ it 'shows the "Browse Files" link' do
click_link('History')
expect(page).to have_link('Browse Files')
@@ -121,6 +130,14 @@ describe 'User browses files' do
wait_for_requests
expect(page).to have_content('*.rbc')
end
+
+ it 'is possible to blame' do
+ click_link 'Blame'
+
+ expect(page).to have_content "*.rb"
+ expect(page).to have_content "Dmitriy Zaporozhets"
+ expect(page).to have_content "Initial commit"
+ end
end
context 'when browsing a raw file' do
@@ -133,57 +150,4 @@ describe 'User browses files' do
expect(source).to eq('') # Body is filled in by gitlab-workhorse
end
end
-
- context 'when browsing an LFS object' do
- before do
- allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true)
- visit(project_tree_path(project, 'lfs'))
- end
-
- it 'shows an LFS object' do
- click_link('files')
- click_link('lfs')
- click_link('lfs_object.iso')
-
- expect(page).to have_content('Download (1.5 MB)')
- expect(page).not_to have_content('version https://git-lfs.github.com/spec/v1')
- expect(page).not_to have_content('oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897')
- expect(page).not_to have_content('size 1575078')
-
- page.within('.content') do
- expect(page).to have_content('Delete')
- expect(page).to have_content('History')
- expect(page).to have_content('Permalink')
- expect(page).to have_content('Replace')
- expect(page).not_to have_content('Annotate')
- expect(page).not_to have_content('Blame')
- expect(page).not_to have_content('Edit')
- expect(page).to have_link('Download')
- end
- end
- end
-
- context 'when previewing a file content' do
- before do
- visit(tree_path_root_ref)
- end
-
- it 'shows a preview of a file content', :js do
- find('.add-to-tree').click
- click_link('Upload file')
- drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'))
-
- page.within('#modal-upload-blob') do
- fill_in(:commit_message, with: 'New commit message')
- fill_in(:branch_name, with: 'new_branch_name', visible: true)
- click_button('Upload file')
- end
-
- wait_for_all_requests
-
- visit(project_blob_path(project, 'new_branch_name/logo_sample.svg'))
-
- expect(page).to have_css('.file-content img')
- end
- end
end
diff --git a/spec/features/projects/files/user_browses_lfs_files_spec.rb b/spec/features/projects/files/user_browses_lfs_files_spec.rb
new file mode 100644
index 00000000000..c559a301ca1
--- /dev/null
+++ b/spec/features/projects/files/user_browses_lfs_files_spec.rb
@@ -0,0 +1,57 @@
+require 'spec_helper'
+
+describe 'Projects > Files > User browses LFS files' do
+ let(:project) { create(:project, :repository) }
+ let(:user) { project.owner }
+
+ before do
+ sign_in(user)
+ end
+
+ context 'when LFS is disabled', :js do
+ before do
+ allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false)
+ visit project_tree_path(project, 'lfs')
+ end
+
+ it 'is possible to see raw content of LFS pointer' do
+ click_link 'files'
+ click_link 'lfs'
+ click_link 'lfs_object.iso'
+
+ expect(page).to have_content 'version https://git-lfs.github.com/spec/v1'
+ expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
+ expect(page).to have_content 'size 1575078'
+ expect(page).not_to have_content 'Download (1.5 MB)'
+ end
+ end
+
+ context 'when LFS is enabled' do
+ before do
+ allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true)
+ visit project_tree_path(project, 'lfs')
+ end
+
+ it 'shows an LFS object' do
+ click_link('files')
+ click_link('lfs')
+ click_link('lfs_object.iso')
+
+ expect(page).to have_content('Download (1.5 MB)')
+ expect(page).not_to have_content('version https://git-lfs.github.com/spec/v1')
+ expect(page).not_to have_content('oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897')
+ expect(page).not_to have_content('size 1575078')
+
+ page.within('.content') do
+ expect(page).to have_content('Delete')
+ expect(page).to have_content('History')
+ expect(page).to have_content('Permalink')
+ expect(page).to have_content('Replace')
+ expect(page).not_to have_content('Annotate')
+ expect(page).not_to have_content('Blame')
+ expect(page).not_to have_content('Edit')
+ expect(page).to have_link('Download')
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/user_creates_directory_spec.rb b/spec/features/projects/files/user_creates_directory_spec.rb
index 00e48f6fabd..847b5f0860f 100644
--- a/spec/features/projects/user_creates_directory_spec.rb
+++ b/spec/features/projects/files/user_creates_directory_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'User creates a directory', :js do
+describe 'Projects > Files > User creates a directory', :js do
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
diff --git a/spec/features/projects/user_creates_files_spec.rb b/spec/features/projects/files/user_creates_files_spec.rb
index 8993533676b..208cc8d81f7 100644
--- a/spec/features/projects/user_creates_files_spec.rb
+++ b/spec/features/projects/files/user_creates_files_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User creates files' do
+describe 'Projects > Files > User creates files' do
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
@@ -59,6 +59,31 @@ describe 'User creates files' do
expect(page).to have_selector('.file-editor')
end
+ def submit_new_file(options)
+ file_name = find('#file_name')
+ file_name.set options[:file_name] || 'README.md'
+
+ file_content = find('#file-content', visible: false)
+ file_content.set options[:file_content] || 'Some content'
+
+ click_button 'Commit changes'
+ end
+
+ it 'allows Chinese characters in file name' do
+ submit_new_file(file_name: '测试.md')
+ expect(page).to have_content 'The file has been successfully created.'
+ end
+
+ it 'allows Chinese characters in directory name' do
+ submit_new_file(file_name: '中文/测试.md')
+ expect(page).to have_content 'The file has been successfully created'
+ end
+
+ it 'does not allow directory traversal in file name' do
+ submit_new_file(file_name: '../README.md')
+ expect(page).to have_content 'Path cannot include directory traversal'
+ end
+
it 'creates and commit a new file', :js do
find('#editor')
execute_script("ace.edit('editor').setValue('*.rbca')")
diff --git a/spec/features/projects/user_deletes_files_spec.rb b/spec/features/projects/files/user_deletes_files_spec.rb
index 9d55197e719..36d3e001a64 100644
--- a/spec/features/projects/user_deletes_files_spec.rb
+++ b/spec/features/projects/files/user_deletes_files_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User deletes files' do
+describe 'Projects > Files > User deletes files' do
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
diff --git a/spec/features/projects/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb
index 05c2be473da..dc6e4fd27cb 100644
--- a/spec/features/projects/user_edits_files_spec.rb
+++ b/spec/features/projects/files/user_edits_files_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User edits files' do
+describe 'Projects > Files > User edits files' do
include ProjectForksHelper
let(:project) { create(:project, :repository, name: 'Shop') }
let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
@@ -12,6 +12,23 @@ describe 'User edits files' do
sign_in(user)
end
+ shared_examples 'unavailable for an archived project' do
+ it 'does not show the edit link for an archived project', :js do
+ project.update!(archived: true)
+ visit project_tree_path(project, project.repository.root_ref)
+
+ click_link('.gitignore')
+
+ aggregate_failures 'available edit buttons' do
+ expect(page).not_to have_text('Edit')
+ expect(page).not_to have_text('Web IDE')
+
+ expect(page).not_to have_text('Replace')
+ expect(page).not_to have_text('Delete')
+ end
+ end
+ end
+
context 'when an user has write access' do
before do
project.add_master(user)
@@ -85,6 +102,8 @@ describe 'User edits files' do
expect(page).to have_css('.line_holder.new')
end
+
+ it_behaves_like 'unavailable for an archived project'
end
context 'when an user does not have write access' do
@@ -168,6 +187,10 @@ describe 'User edits files' do
expect(page).to have_content("From #{forked_project.full_path}")
expect(page).to have_content("into #{project2.full_path}")
end
+
+ it_behaves_like 'unavailable for an archived project' do
+ let(:project) { project2 }
+ end
end
end
end
diff --git a/spec/features/projects/files/user_reads_pipeline_status_spec.rb b/spec/features/projects/files/user_reads_pipeline_status_spec.rb
new file mode 100644
index 00000000000..2fb9da2f0a2
--- /dev/null
+++ b/spec/features/projects/files/user_reads_pipeline_status_spec.rb
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe 'user reads pipeline status', :js do
+ let(:project) { create(:project, :repository) }
+ let(:user) { create(:user) }
+ let(:v110_pipeline) { create_pipeline('v1.1.0', 'success') }
+ let(:x110_pipeline) { create_pipeline('x1.1.0', 'failed') }
+
+ before do
+ project.add_master(user)
+
+ project.repository.add_tag(user, 'x1.1.0', 'v1.1.0')
+ v110_pipeline
+ x110_pipeline
+
+ sign_in(user)
+ end
+
+ shared_examples 'visiting project tree' do
+ scenario 'sees the correct pipeline status' do
+ visit project_tree_path(project, expected_pipeline.ref)
+ wait_for_requests
+
+ page.within('.blob-commit-info') do
+ expect(page).to have_link('', href: project_pipeline_path(project, expected_pipeline))
+ expect(page).to have_selector(".ci-status-icon-#{expected_pipeline.status}")
+ end
+ end
+ end
+
+ it_behaves_like 'visiting project tree' do
+ let(:expected_pipeline) { v110_pipeline }
+ end
+
+ it_behaves_like 'visiting project tree' do
+ let(:expected_pipeline) { x110_pipeline }
+ end
+
+ def create_pipeline(ref, status)
+ create(:ci_pipeline,
+ project: project,
+ ref: ref,
+ sha: project.commit(ref).sha,
+ status: status)
+ end
+end
diff --git a/spec/features/projects/user_replaces_files_spec.rb b/spec/features/projects/files/user_replaces_files_spec.rb
index 74872403b35..9ac3417b671 100644
--- a/spec/features/projects/user_replaces_files_spec.rb
+++ b/spec/features/projects/files/user_replaces_files_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User replaces files' do
+describe 'Projects > Files > User replaces files' do
include DropzoneHelper
let(:fork_message) do
diff --git a/spec/features/projects/files/user_searches_for_files_spec.rb b/spec/features/projects/files/user_searches_for_files_spec.rb
index a105685bca7..a90e4918fb1 100644
--- a/spec/features/projects/files/user_searches_for_files_spec.rb
+++ b/spec/features/projects/files/user_searches_for_files_spec.rb
@@ -1,8 +1,7 @@
require 'spec_helper'
-describe 'User searches for files' do
- let(:user) { create(:user) }
- let(:project) { create(:project, :repository) }
+describe 'Projects > Files > User searches for files' do
+ let(:user) { project.owner }
before do
sign_in(user)
@@ -10,11 +9,10 @@ describe 'User searches for files' do
describe 'project main screen' do
context 'when project is empty' do
- let(:empty_project) { create(:project) }
+ let(:project) { create(:project) }
before do
- empty_project.add_developer(user)
- visit project_path(empty_project)
+ visit project_path(project)
end
it 'does not show any result' do
@@ -26,6 +24,8 @@ describe 'User searches for files' do
end
context 'when project is not empty' do
+ let(:project) { create(:project, :repository) }
+
before do
project.add_developer(user)
visit project_path(project)
@@ -38,16 +38,16 @@ describe 'User searches for files' do
end
describe 'project tree screen' do
+ let(:project) { create(:project, :repository) }
+
before do
project.add_developer(user)
visit project_tree_path(project, project.default_branch)
end
- it 'shows "Find file" button' do
+ it 'shows found files' do
expect(page).to have_selector('.tree-controls .shortcuts-find-file')
- end
- it 'shows found files' do
fill_in('search', with: 'coffee')
click_button('Go')
diff --git a/spec/features/projects/user_uploads_files_spec.rb b/spec/features/projects/files/user_uploads_files_spec.rb
index 75898afcda9..7a1e3a8bcce 100644
--- a/spec/features/projects/user_uploads_files_spec.rb
+++ b/spec/features/projects/files/user_uploads_files_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User uploads files' do
+describe 'Projects > Files > User uploads files' do
include DropzoneHelper
let(:fork_message) do
@@ -11,7 +11,7 @@ describe 'User uploads files' do
let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
- let(:user) { create(:user) }
+ let(:user) { project.creator }
before do
project.add_master(user)
@@ -23,7 +23,7 @@ describe 'User uploads files' do
visit(project_tree_path_root_ref)
end
- it 'uploads and commit a new file', :js do
+ it 'uploads and commit a new text file', :js do
find('.add-to-tree').click
click_link('Upload file')
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
@@ -46,6 +46,24 @@ describe 'User uploads files' do
expect(page).to have_content('Lorem ipsum dolor sit amet')
expect(page).to have_content('Sed ut perspiciatis unde omnis')
end
+
+ it 'uploads and commit a new image file', :js do
+ find('.add-to-tree').click
+ click_link('Upload file')
+ drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'))
+
+ page.within('#modal-upload-blob') do
+ fill_in(:commit_message, with: 'New commit message')
+ fill_in(:branch_name, with: 'new_branch_name', visible: true)
+ click_button('Upload file')
+ end
+
+ wait_for_all_requests
+
+ visit(project_blob_path(project, 'new_branch_name/logo_sample.svg'))
+
+ expect(page).to have_css('.file-content img')
+ end
end
context 'when an user does not have write access' do
diff --git a/spec/features/projects/guest_navigation_menu_spec.rb b/spec/features/projects/guest_navigation_menu_spec.rb
deleted file mode 100644
index 199682b943c..00000000000
--- a/spec/features/projects/guest_navigation_menu_spec.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-require 'spec_helper'
-
-describe 'Guest navigation menu' do
- let(:project) { create(:project, :private, public_builds: false) }
- let(:guest) { create(:user) }
-
- before do
- project.add_guest(guest)
-
- sign_in(guest)
- end
-
- it 'shows allowed tabs only' do
- visit project_path(project)
-
- within('.nav-sidebar') do
- expect(page).to have_content 'Overview'
- expect(page).to have_content 'Issues'
- expect(page).to have_content 'Wiki'
-
- expect(page).not_to have_content 'Repository'
- expect(page).not_to have_content 'Pipelines'
- expect(page).not_to have_content 'Merge Requests'
- end
- end
-
- it 'does not show fork button' do
- visit project_path(project)
-
- within('.count-buttons') do
- expect(page).not_to have_link 'Fork'
- end
- end
-
- it 'does not show clone path' do
- visit project_path(project)
-
- within('.project-repo-buttons') do
- expect(page).not_to have_selector '.project-clone-holder'
- end
- end
-
- describe 'project landing page' do
- before do
- project.project_feature.update!(
- issues_access_level: ProjectFeature::DISABLED,
- wiki_access_level: ProjectFeature::DISABLED
- )
- end
-
- it 'does not show the project file list landing page' do
- visit project_path(project)
-
- expect(page).not_to have_selector '.project-stats'
- expect(page).not_to have_selector '.project-last-commit'
- expect(page).not_to have_selector '.project-show-files'
- expect(page).to have_selector '.project-show-customize_workflow'
- end
-
- it 'shows the customize workflow when issues and wiki are disabled' do
- visit project_path(project)
-
- expect(page).to have_selector '.project-show-customize_workflow'
- end
-
- it 'shows the wiki when enabled' do
- project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE)
-
- visit project_path(project)
-
- expect(page).to have_selector '.project-show-wiki'
- end
-
- it 'shows the issues when enabled' do
- project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
-
- visit project_path(project)
-
- expect(page).to have_selector '.issues-list'
- end
- end
-end
diff --git a/spec/features/projects/issues/user_views_issue_spec.rb b/spec/features/projects/issues/user_views_issue_spec.rb
index f7f2cde3d64..4093876c289 100644
--- a/spec/features/projects/issues/user_views_issue_spec.rb
+++ b/spec/features/projects/issues/user_views_issue_spec.rb
@@ -6,11 +6,27 @@ describe "User views issue" do
set(:issue) { create(:issue, project: project, description: "# Description header", author: user) }
before do
- project.add_guest(user)
+ project.add_developer(user)
sign_in(user)
visit(project_issue_path(project, issue))
end
it { expect(page).to have_header_with_correct_id_and_link(1, "Description header", "description-header") }
+
+ it 'shows the merge request and issue actions', :aggregate_failures do
+ expect(page).to have_link('New issue')
+ expect(page).to have_button('Create merge request')
+ expect(page).to have_link('Close issue')
+ end
+
+ context 'when the project is archived' do
+ let(:project) { create(:project, :public, :archived) }
+
+ it 'hides the merge request and issue actions', :aggregate_failures do
+ expect(page).not_to have_link('New issue')
+ expect(page).not_to have_button('Create merge request')
+ expect(page).not_to have_link('Close issue')
+ end
+ end
end
diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb
index 749a1b81872..a460024542c 100644
--- a/spec/features/projects/jobs_spec.rb
+++ b/spec/features/projects/jobs_spec.rb
@@ -464,6 +464,17 @@ feature 'Jobs' do
expect(page).to have_content('This job has been skipped')
end
end
+
+ context 'when job is failed but has no trace' do
+ let(:job) { create(:ci_build, :failed, pipeline: pipeline) }
+
+ it 'renders empty state' do
+ visit project_job_path(project, job)
+
+ expect(job).not_to have_trace
+ expect(page).to have_content('This job does not have a trace.')
+ end
+ end
end
describe "POST /:project/jobs/:id/cancel", :js do
diff --git a/spec/features/projects/merge_request_button_spec.rb b/spec/features/projects/merge_request_button_spec.rb
index 40689964b91..b571d5a0e26 100644
--- a/spec/features/projects/merge_request_button_spec.rb
+++ b/spec/features/projects/merge_request_button_spec.rb
@@ -45,6 +45,18 @@ feature 'Merge Request button' do
end
end
end
+
+ context 'when the project is archived' do
+ it 'hides the link' do
+ project.update!(archived: true)
+
+ visit url
+
+ within("#content-body") do
+ expect(page).not_to have_link(label)
+ end
+ end
+ end
end
context 'logged in as non-member' do
diff --git a/spec/features/projects/merge_requests/user_reverts_merge_request_spec.rb b/spec/features/projects/merge_requests/user_reverts_merge_request_spec.rb
index a41d683dbbb..f3e97bc9eb2 100644
--- a/spec/features/projects/merge_requests/user_reverts_merge_request_spec.rb
+++ b/spec/features/projects/merge_requests/user_reverts_merge_request_spec.rb
@@ -56,4 +56,12 @@ describe 'User reverts a merge request', :js do
expect(page).to have_content('The merge request has been successfully reverted. You can now submit a merge request to get this change into the original branch.')
end
+
+ it 'cannot revert a merge requests for an archived project' do
+ project.update!(archived: true)
+
+ visit(merge_request_path(merge_request))
+
+ expect(page).not_to have_link('Revert')
+ end
end
diff --git a/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb b/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb
index bf95dbb7d09..115e548b691 100644
--- a/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb
+++ b/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb
@@ -94,6 +94,18 @@ describe 'User views open merge requests' do
end
include_examples 'shows merge requests'
+
+ it 'shows the new merge request button' do
+ expect(page).to have_link('New merge request')
+ end
+
+ context 'when the project is archived' do
+ let(:project) { create(:project, :public, :repository, :archived) }
+
+ it 'hides the new merge request button' do
+ expect(page).not_to have_link('New merge request')
+ end
+ end
end
end
diff --git a/spec/features/projects/project_settings_spec.rb b/spec/features/projects/project_settings_spec.rb
deleted file mode 100644
index a3ea778d401..00000000000
--- a/spec/features/projects/project_settings_spec.rb
+++ /dev/null
@@ -1,205 +0,0 @@
-require 'spec_helper'
-
-describe 'Edit Project Settings' do
- include Select2Helper
-
- let(:user) { create(:user) }
- let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') }
-
- before do
- sign_in(user)
- end
-
- describe 'Project settings section', :js do
- it 'shows errors for invalid project name' do
- visit edit_project_path(project)
- fill_in 'project_name_edit', with: 'foo&bar'
- page.within('.general-settings') do
- click_button 'Save changes'
- end
- expect(page).to have_field 'project_name_edit', with: 'foo&bar'
- expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
- expect(page).to have_button 'Save changes'
- end
-
- it 'shows a successful notice when the project is updated' do
- visit edit_project_path(project)
- fill_in 'project_name_edit', with: 'hello world'
- page.within('.general-settings') do
- click_button 'Save changes'
- end
- expect(page).to have_content "Project 'hello world' was successfully updated."
- end
- end
-
- describe 'Merge request settings section' do
- it 'shows "Merge commit" strategy' do
- visit edit_project_path(project)
-
- page.within '.merge-requests-feature' do
- expect(page).to have_content 'Merge commit'
- end
- end
-
- it 'shows "Merge commit with semi-linear history " strategy' do
- visit edit_project_path(project)
-
- page.within '.merge-requests-feature' do
- expect(page).to have_content 'Merge commit with semi-linear history'
- end
- end
-
- it 'shows "Fast-forward merge" strategy' do
- visit edit_project_path(project)
-
- page.within '.merge-requests-feature' do
- expect(page).to have_content 'Fast-forward merge'
- end
- end
- end
-
- describe 'Rename repository section' do
- context 'with invalid characters' do
- it 'shows errors for invalid project path/name' do
- rename_project(project, name: 'foo&bar', path: 'foo&bar')
- expect(page).to have_field 'Project name', with: 'foo&bar'
- expect(page).to have_field 'Path', with: 'foo&bar'
- expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
- expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
- end
- end
-
- context 'when changing project name' do
- it 'renames the repository' do
- rename_project(project, name: 'bar')
- expect(find('.breadcrumbs')).to have_content(project.name)
- end
-
- context 'with emojis' do
- it 'shows error for invalid project name' do
- rename_project(project, name: '🚀 foo bar ☁️')
- expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️'
- expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'."
- end
- end
- end
-
- context 'when changing project path' do
- let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
-
- before(:context) do
- TestEnv.clean_test_path
- end
-
- after do
- TestEnv.clean_test_path
- end
-
- specify 'the project is accessible via the new path' do
- rename_project(project, path: 'bar')
- new_path = namespace_project_path(project.namespace, 'bar')
- visit new_path
- expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
- end
-
- specify 'the project is accessible via a redirect from the old path' do
- old_path = project_path(project)
- rename_project(project, path: 'bar')
- new_path = namespace_project_path(project.namespace, 'bar')
- visit old_path
- expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
- end
-
- context 'and a new project is added with the same path' do
- it 'overrides the redirect' do
- old_path = project_path(project)
- rename_project(project, path: 'bar')
- new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
- visit old_path
- expect(current_path).to eq(old_path)
- expect(find('.breadcrumbs')).to have_content(new_project.name)
- end
- end
- end
- end
-
- describe 'Transfer project section', :js do
- let!(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
- let!(:group) { create(:group) }
-
- before(:context) do
- TestEnv.clean_test_path
- end
-
- before do
- group.add_owner(user)
- end
-
- after do
- TestEnv.clean_test_path
- end
-
- specify 'the project is accessible via the new path' do
- transfer_project(project, group)
- new_path = namespace_project_path(group, project)
-
- visit new_path
- wait_for_requests
-
- expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
- end
-
- specify 'the project is accessible via a redirect from the old path' do
- old_path = project_path(project)
- transfer_project(project, group)
- new_path = namespace_project_path(group, project)
-
- visit old_path
- wait_for_requests
-
- expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
- end
-
- context 'and a new project is added with the same path' do
- it 'overrides the redirect' do
- old_path = project_path(project)
- transfer_project(project, group)
- new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
- visit old_path
- expect(current_path).to eq(old_path)
- expect(find('.breadcrumbs')).to have_content(new_project.name)
- end
- end
- end
-end
-
-def rename_project(project, name: nil, path: nil)
- visit edit_project_path(project)
- fill_in('project_name', with: name) if name
- fill_in('Path', with: path) if path
- click_button('Rename project')
- wait_for_edit_project_page_reload
- project.reload
-end
-
-def transfer_project(project, namespace)
- visit edit_project_path(project)
- select2(namespace.id, from: '#new_namespace_id')
- click_button('Transfer project')
- confirm_transfer_modal
- wait_for_edit_project_page_reload
- project.reload
-end
-
-def confirm_transfer_modal
- fill_in('confirm_name_input', with: project.path)
- click_button 'Confirm'
-end
-
-def wait_for_edit_project_page_reload
- expect(find('.project-edit-container')).to have_content('Rename repository')
-end
diff --git a/spec/features/projects/settings/forked_project_settings_spec.rb b/spec/features/projects/settings/forked_project_settings_spec.rb
index 28954a4fb40..a4d1b78b83b 100644
--- a/spec/features/projects/settings/forked_project_settings_spec.rb
+++ b/spec/features/projects/settings/forked_project_settings_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Settings for a forked project', :js do
+describe 'Projects > Settings > For a forked project', :js do
include ProjectForksHelper
let(:user) { create(:user) }
let(:original_project) { create(:project) }
diff --git a/spec/features/projects/settings/integration_settings_spec.rb b/spec/features/projects/settings/integration_settings_spec.rb
index f6a1a46df11..5178d63050e 100644
--- a/spec/features/projects/settings/integration_settings_spec.rb
+++ b/spec/features/projects/settings/integration_settings_spec.rb
@@ -1,20 +1,20 @@
require 'spec_helper'
-feature 'Integration settings' do
+describe 'Projects > Settings > Integration settings' do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
let(:integrations_path) { project_settings_integrations_path(project) }
- background do
+ before do
sign_in(user)
project.add_role(user, role)
end
context 'for developer' do
- given(:role) { :developer }
+ let(:role) { :developer }
- scenario 'to be disallowed to view' do
+ it 'to be disallowed to view' do
visit integrations_path
expect(page.status_code).to eq(404)
@@ -22,13 +22,13 @@ feature 'Integration settings' do
end
context 'for master' do
- given(:role) { :master }
+ let(:role) { :master }
context 'Webhooks' do
let(:hook) { create(:project_hook, :all_events_enabled, enable_ssl_verification: true, project: project) }
let(:url) { generate(:url) }
- scenario 'show list of webhooks' do
+ it 'show list of webhooks' do
hook
visit integrations_path
@@ -46,7 +46,7 @@ feature 'Integration settings' do
expect(page).to have_content('Wiki page events')
end
- scenario 'create webhook' do
+ it 'create webhook' do
visit integrations_path
fill_in 'hook_url', with: url
@@ -63,7 +63,7 @@ feature 'Integration settings' do
expect(page).to have_content('Job events')
end
- scenario 'edit existing webhook' do
+ it 'edit existing webhook' do
hook
visit integrations_path
@@ -76,7 +76,7 @@ feature 'Integration settings' do
expect(page).to have_content(url)
end
- scenario 'test existing webhook', :js do
+ it 'test existing webhook', :js do
WebMock.stub_request(:post, hook.url)
visit integrations_path
@@ -87,14 +87,14 @@ feature 'Integration settings' do
end
context 'remove existing webhook' do
- scenario 'from webhooks list page' do
+ it 'from webhooks list page' do
hook
visit integrations_path
expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1)
end
- scenario 'from webhook edit page' do
+ it 'from webhook edit page' do
hook
visit integrations_path
click_link 'Edit'
@@ -108,7 +108,7 @@ feature 'Integration settings' do
let(:hook) { create(:project_hook, project: project) }
let(:hook_log) { create(:web_hook_log, web_hook: hook, internal_error_message: 'some error') }
- scenario 'show list of hook logs' do
+ it 'show list of hook logs' do
hook_log
visit edit_project_hook_path(project, hook)
@@ -116,7 +116,7 @@ feature 'Integration settings' do
expect(page).to have_content(hook_log.url)
end
- scenario 'show hook log details' do
+ it 'show hook log details' do
hook_log
visit edit_project_hook_path(project, hook)
click_link 'View details'
@@ -126,7 +126,7 @@ feature 'Integration settings' do
expect(page).to have_content('Resend Request')
end
- scenario 'retry hook log' do
+ it 'retry hook log' do
WebMock.stub_request(:post, hook.url)
hook_log
diff --git a/spec/features/projects/settings/lfs_settings_spec.rb b/spec/features/projects/settings/lfs_settings_spec.rb
new file mode 100644
index 00000000000..0fd28a5681c
--- /dev/null
+++ b/spec/features/projects/settings/lfs_settings_spec.rb
@@ -0,0 +1,21 @@
+require 'rails_helper'
+
+describe 'Projects > Settings > LFS settings' do
+ let(:admin) { create(:admin) }
+ let(:project) { create(:project) }
+
+ context 'LFS enabled setting' do
+ before do
+ allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
+
+ sign_in(admin)
+ end
+
+ it 'displays the correct elements', :js do
+ visit edit_project_path(project)
+
+ expect(page).to have_content('Git Large File Storage')
+ expect(page).to have_selector('input[name="project[lfs_enabled]"] + button', visible: true)
+ end
+ end
+end
diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb
index d0720855564..d9020333f28 100644
--- a/spec/features/projects/settings/pipelines_settings_spec.rb
+++ b/spec/features/projects/settings/pipelines_settings_spec.rb
@@ -1,19 +1,19 @@
require 'spec_helper'
-feature "Pipelines settings" do
+describe "Projects > Settings > Pipelines settings" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
- background do
+ before do
sign_in(user)
project.add_role(user, role)
end
context 'for developer' do
- given(:role) { :developer }
+ let(:role) { :developer }
- scenario 'to be disallowed to view' do
+ it 'to be disallowed to view' do
visit project_settings_ci_cd_path(project)
expect(page.status_code).to eq(404)
@@ -21,9 +21,9 @@ feature "Pipelines settings" do
end
context 'for master' do
- given(:role) { :master }
+ let(:role) { :master }
- scenario 'be allowed to change' do
+ it 'be allowed to change' do
visit project_settings_ci_cd_path(project)
fill_in('Test coverage parsing', with: 'coverage_regex')
@@ -34,7 +34,7 @@ feature "Pipelines settings" do
expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
end
- scenario 'updates auto_cancel_pending_pipelines' do
+ it 'updates auto_cancel_pending_pipelines' do
visit project_settings_ci_cd_path(project)
page.check('Auto-cancel redundant, pending pipelines')
diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb
index f2c371b7df5..e1dfe617691 100644
--- a/spec/features/projects/settings/repository_settings_spec.rb
+++ b/spec/features/projects/settings/repository_settings_spec.rb
@@ -1,19 +1,19 @@
require 'spec_helper'
-feature 'Repository settings' do
+describe 'Projects > Settings > Repository settings' do
let(:project) { create(:project_empty_repo) }
let(:user) { create(:user) }
let(:role) { :developer }
- background do
+ before do
project.add_role(user, role)
sign_in(user)
end
context 'for developer' do
- given(:role) { :developer }
+ let(:role) { :developer }
- scenario 'is not allowed to view' do
+ it 'is not allowed to view' do
visit project_settings_repository_path(project)
expect(page.status_code).to eq(404)
@@ -21,14 +21,14 @@ feature 'Repository settings' do
end
context 'for master' do
- given(:role) { :master }
+ let(:role) { :master }
context 'Deploy Keys', :js do
let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) }
let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) }
let(:new_ssh_key) { attributes_for(:key)[:key] }
- scenario 'get list of keys' do
+ it 'get list of keys' do
project.deploy_keys << private_deploy_key
project.deploy_keys << public_deploy_key
@@ -38,7 +38,7 @@ feature 'Repository settings' do
expect(page).to have_content('public_deploy_key')
end
- scenario 'add a new deploy key' do
+ it 'add a new deploy key' do
visit project_settings_repository_path(project)
fill_in 'deploy_key_title', with: 'new_deploy_key'
@@ -50,7 +50,7 @@ feature 'Repository settings' do
expect(page).to have_content('Write access allowed')
end
- scenario 'edit an existing deploy key' do
+ it 'edit an existing deploy key' do
project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project)
@@ -64,7 +64,7 @@ feature 'Repository settings' do
expect(page).to have_content('Write access allowed')
end
- scenario 'edit a deploy key from projects user has access to' do
+ it 'edit a deploy key from projects user has access to' do
project2 = create(:project_empty_repo)
project2.add_role(user, role)
project2.deploy_keys << private_deploy_key
@@ -79,7 +79,7 @@ feature 'Repository settings' do
expect(page).to have_content('updated_deploy_key')
end
- scenario 'remove an existing deploy key' do
+ it 'remove an existing deploy key' do
project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project)
diff --git a/spec/features/projects/user_archives_project_spec.rb b/spec/features/projects/settings/user_archives_project_spec.rb
index 72063d13c2a..38c8a8c2468 100644
--- a/spec/features/projects/user_archives_project_spec.rb
+++ b/spec/features/projects/settings/user_archives_project_spec.rb
@@ -1,21 +1,19 @@
require 'spec_helper'
-describe 'User archives a project' do
+describe 'Projects > Settings > User archives a project' do
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in(user)
+
+ visit edit_project_path(project)
end
context 'when a project is archived' do
let(:project) { create(:project, :archived, namespace: user.namespace) }
- before do
- visit(edit_project_path(project))
- end
-
it 'unarchives a project' do
expect(page).to have_content('Unarchive project')
@@ -28,10 +26,6 @@ describe 'User archives a project' do
context 'when a project is unarchived' do
let(:project) { create(:project, :repository, namespace: user.namespace) }
- before do
- visit(edit_project_path(project))
- end
-
it 'archives a project' do
expect(page).to have_content('Archive project')
diff --git a/spec/features/projects/settings/user_changes_avatar_spec.rb b/spec/features/projects/settings/user_changes_avatar_spec.rb
new file mode 100644
index 00000000000..2dcc79d8a12
--- /dev/null
+++ b/spec/features/projects/settings/user_changes_avatar_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+describe 'Projects > Settings > User changes avatar' do
+ let(:project) { create(:project, :repository) }
+ let(:user) { project.creator }
+
+ before do
+ project.add_master(user)
+ sign_in(user)
+ end
+
+ it 'saves the new avatar' do
+ expect(project.reload.avatar.url).to be_nil
+
+ save_avatar(project)
+
+ expect(project.reload.avatar.url).to eq "/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
+ end
+
+ context 'with an avatar already set' do
+ before do
+ save_avatar(project)
+ end
+
+ it 'is possible to remove the avatar' do
+ click_link 'Remove avatar'
+
+ expect(page).not_to have_link('Remove avatar')
+
+ expect(project.reload.avatar.url).to be_nil
+ end
+ end
+
+ def save_avatar(project)
+ visit edit_project_path(project)
+ attach_file(
+ :project_avatar,
+ File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
+ )
+ page.within '.general-settings' do
+ click_button 'Save changes'
+ end
+ end
+end
diff --git a/spec/features/projects/settings/user_changes_default_branch_spec.rb b/spec/features/projects/settings/user_changes_default_branch_spec.rb
new file mode 100644
index 00000000000..e925539351d
--- /dev/null
+++ b/spec/features/projects/settings/user_changes_default_branch_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe 'Projects > Settings > User changes default branch' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :repository, namespace: user.namespace) }
+
+ before do
+ sign_in(user)
+ visit edit_project_path(project)
+ end
+
+ it 'allows to change the default branch' do
+ select 'fix', from: 'project_default_branch'
+ page.within '.general-settings' do
+ click_button 'Save changes'
+ end
+
+ expect(find(:css, 'select#project_default_branch').value).to eq 'fix'
+ end
+end
diff --git a/spec/features/projects/settings/user_manages_group_links_spec.rb b/spec/features/projects/settings/user_manages_group_links_spec.rb
index 91e8059865c..fdf42797091 100644
--- a/spec/features/projects/settings/user_manages_group_links_spec.rb
+++ b/spec/features/projects/settings/user_manages_group_links_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User manages group links' do
+describe 'Projects > Settings > User manages group links' do
include Select2Helper
let(:user) { create(:user) }
diff --git a/spec/features/projects/settings/merge_requests_settings_spec.rb b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
index 015db603d33..b6e65fcbda1 100644
--- a/spec/features/projects/settings/merge_requests_settings_spec.rb
+++ b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
@@ -1,21 +1,35 @@
require 'spec_helper'
-feature 'Project settings > Merge Requests', :js do
- let(:project) { create(:project, :public) }
+describe 'Projects > Settings > User manages merge request settings' do
let(:user) { create(:user) }
+ let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') }
- background do
- project.add_master(user)
+ before do
sign_in(user)
+ visit edit_project_path(project)
end
- context 'when Merge Request and Pipelines are initially enabled' do
- context 'when Pipelines are initially enabled' do
- before do
- visit edit_project_path(project)
- end
+ it 'shows "Merge commit" strategy' do
+ page.within '.merge-requests-feature' do
+ expect(page).to have_content 'Merge commit'
+ end
+ end
+
+ it 'shows "Merge commit with semi-linear history " strategy' do
+ page.within '.merge-requests-feature' do
+ expect(page).to have_content 'Merge commit with semi-linear history'
+ end
+ end
- scenario 'shows the Merge Requests settings' do
+ it 'shows "Fast-forward merge" strategy' do
+ page.within '.merge-requests-feature' do
+ expect(page).to have_content 'Fast-forward merge'
+ end
+ end
+
+ context 'when Merge Request and Pipelines are initially enabled', :js do
+ context 'when Pipelines are initially enabled' do
+ it 'shows the Merge Requests settings' do
expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
@@ -29,13 +43,13 @@ feature 'Project settings > Merge Requests', :js do
end
end
- context 'when Pipelines are initially disabled' do
+ context 'when Pipelines are initially disabled', :js do
before do
project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED)
visit edit_project_path(project)
end
- scenario 'shows the Merge Requests settings that do not depend on Builds feature' do
+ it 'shows the Merge Requests settings that do not depend on Builds feature' do
expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
@@ -50,13 +64,13 @@ feature 'Project settings > Merge Requests', :js do
end
end
- context 'when Merge Request are initially disabled' do
+ context 'when Merge Request are initially disabled', :js do
before do
project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED)
visit edit_project_path(project)
end
- scenario 'does not show the Merge Requests settings' do
+ it 'does not show the Merge Requests settings' do
expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved')
@@ -70,17 +84,13 @@ feature 'Project settings > Merge Requests', :js do
end
end
- describe 'Checkbox to enable merge request link' do
- before do
- visit edit_project_path(project)
- end
-
- scenario 'is initially checked' do
+ describe 'Checkbox to enable merge request link', :js do
+ it 'is initially checked' do
checkbox = find_field('project_printing_merge_request_link_enabled')
expect(checkbox).to be_checked
end
- scenario 'when unchecked sets :printing_merge_request_link_enabled to false' do
+ it 'when unchecked sets :printing_merge_request_link_enabled to false' do
uncheck('project_printing_merge_request_link_enabled')
within('.merge-request-settings-form') do
click_on('Save changes')
diff --git a/spec/features/projects/settings/user_manages_project_members_spec.rb b/spec/features/projects/settings/user_manages_project_members_spec.rb
index 0a4f57bcd21..8af95522165 100644
--- a/spec/features/projects/settings/user_manages_project_members_spec.rb
+++ b/spec/features/projects/settings/user_manages_project_members_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User manages project members' do
+describe 'Projects > Settings > User manages project members' do
let(:group) { create(:group, name: 'OpenSource') }
let(:project) { create(:project) }
let(:project2) { create(:project) }
diff --git a/spec/features/projects/settings/user_renames_a_project_spec.rb b/spec/features/projects/settings/user_renames_a_project_spec.rb
new file mode 100644
index 00000000000..64c9af4b706
--- /dev/null
+++ b/spec/features/projects/settings/user_renames_a_project_spec.rb
@@ -0,0 +1,100 @@
+require 'spec_helper'
+
+describe 'Projects > Settings > User renames a project' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') }
+
+ before do
+ sign_in(user)
+ visit edit_project_path(project)
+ end
+
+ def rename_project(project, name: nil, path: nil)
+ fill_in('project_name', with: name) if name
+ fill_in('Path', with: path) if path
+ click_button('Rename project')
+ wait_for_edit_project_page_reload
+ project.reload
+ end
+
+ def wait_for_edit_project_page_reload
+ expect(find('.project-edit-container')).to have_content('Rename repository')
+ end
+
+ context 'with invalid characters' do
+ it 'shows errors for invalid project path/name' do
+ rename_project(project, name: 'foo&bar', path: 'foo&bar')
+ expect(page).to have_field 'Project name', with: 'foo&bar'
+ expect(page).to have_field 'Path', with: 'foo&bar'
+ expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
+ expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
+ end
+ end
+
+ it 'shows a successful notice when the project is updated' do
+ fill_in 'project_name_edit', with: 'hello world'
+ page.within('.general-settings') do
+ click_button 'Save changes'
+ end
+
+ expect(page).to have_content "Project 'hello world' was successfully updated."
+ end
+
+ context 'when changing project name' do
+ it 'renames the repository' do
+ rename_project(project, name: 'bar')
+ expect(find('.breadcrumbs')).to have_content(project.name)
+ end
+
+ context 'with emojis' do
+ it 'shows error for invalid project name' do
+ rename_project(project, name: '🚀 foo bar ☁️')
+ expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️'
+ expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'."
+ end
+ end
+ end
+
+ context 'when changing project path' do
+ let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
+
+ before(:context) do
+ TestEnv.clean_test_path
+ end
+
+ after do
+ TestEnv.clean_test_path
+ end
+
+ it 'the project is accessible via the new path' do
+ rename_project(project, path: 'bar')
+ new_path = namespace_project_path(project.namespace, 'bar')
+ visit new_path
+
+ expect(current_path).to eq(new_path)
+ expect(find('.breadcrumbs')).to have_content(project.name)
+ end
+
+ it 'the project is accessible via a redirect from the old path' do
+ old_path = project_path(project)
+ rename_project(project, path: 'bar')
+ new_path = namespace_project_path(project.namespace, 'bar')
+ visit old_path
+
+ expect(current_path).to eq(new_path)
+ expect(find('.breadcrumbs')).to have_content(project.name)
+ end
+
+ context 'and a new project is added with the same path' do
+ it 'overrides the redirect' do
+ old_path = project_path(project)
+ rename_project(project, path: 'bar')
+ new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
+ visit old_path
+
+ expect(current_path).to eq(old_path)
+ expect(find('.breadcrumbs')).to have_content(new_project.name)
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/settings/user_tags_project_spec.rb b/spec/features/projects/settings/user_tags_project_spec.rb
new file mode 100644
index 00000000000..57b4b1287fa
--- /dev/null
+++ b/spec/features/projects/settings/user_tags_project_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe 'Projects > Settings > User tags a project' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, namespace: user.namespace) }
+
+ before do
+ sign_in(user)
+ visit edit_project_path(project)
+ end
+
+ context 'when a project is archived' do
+ it 'unarchives a project' do
+ fill_in 'Tags', with: 'tag1, tag2'
+
+ page.within '.general-settings' do
+ click_button 'Save changes'
+ end
+
+ expect(find_field('Tags').value).to eq 'tag1, tag2'
+ end
+ end
+end
diff --git a/spec/features/projects/settings/user_transfers_a_project_spec.rb b/spec/features/projects/settings/user_transfers_a_project_spec.rb
new file mode 100644
index 00000000000..96b7cf1f93b
--- /dev/null
+++ b/spec/features/projects/settings/user_transfers_a_project_spec.rb
@@ -0,0 +1,73 @@
+require 'spec_helper'
+
+describe 'Projects > Settings > User transfers a project', :js do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :repository, namespace: user.namespace) }
+ let(:group) { create(:group) }
+
+ before do
+ group.add_owner(user)
+ sign_in(user)
+ end
+
+ def transfer_project(project, group)
+ visit edit_project_path(project)
+
+ page.within('.js-project-transfer-form') do
+ page.find('.select2-container').click
+ end
+
+ page.find("div[role='option']", text: group.full_name).click
+
+ click_button('Transfer project')
+
+ fill_in 'confirm_name_input', with: project.name
+
+ click_button 'Confirm'
+
+ wait_for_requests
+ end
+
+ it 'allows transferring a project to a group' do
+ old_path = project_path(project)
+ transfer_project(project, group)
+ new_path = namespace_project_path(group, project)
+
+ expect(project.reload.namespace).to eq(group)
+
+ visit new_path
+ wait_for_requests
+
+ expect(current_path).to eq(new_path)
+ expect(find('.breadcrumbs')).to have_content(project.name)
+
+ visit old_path
+ wait_for_requests
+
+ expect(current_path).to eq(new_path)
+ expect(find('.breadcrumbs')).to have_content(project.name)
+ end
+
+ context 'and a new project is added with the same path' do
+ it 'overrides the redirect' do
+ old_path = project_path(project)
+ project_path = project.path
+ transfer_project(project, group)
+ new_project = create(:project, namespace: user.namespace, path: project_path)
+ visit old_path
+
+ expect(current_path).to eq(old_path)
+ expect(find('.breadcrumbs')).to have_content(new_project.name)
+ end
+ end
+
+ context 'when nested groups are available', :nested_groups do
+ it 'allows transferring a project to a subgroup' do
+ subgroup = create(:group, parent: group)
+
+ transfer_project(project, subgroup)
+
+ expect(project.reload.namespace).to eq(subgroup)
+ end
+ end
+end
diff --git a/spec/features/projects/settings/visibility_settings_spec.rb b/spec/features/projects/settings/visibility_settings_spec.rb
index 06f6702670b..2ec6990313f 100644
--- a/spec/features/projects/settings/visibility_settings_spec.rb
+++ b/spec/features/projects/settings/visibility_settings_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Visibility settings', :js do
+describe 'Projects > Settings > Visibility settings', :js do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) }
@@ -10,14 +10,14 @@ feature 'Visibility settings', :js do
visit edit_project_path(project)
end
- scenario 'project visibility select is available' do
+ it 'project visibility select is available' do
visibility_select_container = find('.project-visibility-setting')
expect(visibility_select_container.find('select').value).to eq project.visibility_level.to_s
expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.'
end
- scenario 'project visibility description updates on change' do
+ it 'project visibility description updates on change' do
visibility_select_container = find('.project-visibility-setting')
visibility_select = visibility_select_container.find('select')
visibility_select.select('Private')
@@ -25,6 +25,38 @@ feature 'Visibility settings', :js do
expect(visibility_select.value).to eq '0'
expect(visibility_select_container).to have_content 'Access must be granted explicitly to each user.'
end
+
+ context 'merge requests select' do
+ it 'hides merge requests section' do
+ find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
+
+ expect(page).to have_selector('.merge-requests-feature', visible: false)
+ end
+
+ context 'given project with merge_requests_disabled access level' do
+ let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) }
+
+ it 'hides merge requests section' do
+ expect(page).to have_selector('.merge-requests-feature', visible: false)
+ end
+ end
+ end
+
+ context 'builds select' do
+ it 'hides builds select section' do
+ find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
+
+ expect(page).to have_selector('.builds-feature', visible: false)
+ end
+
+ context 'given project with builds_disabled access level' do
+ let(:project) { create(:project, :builds_disabled, namespace: user.namespace) }
+
+ it 'hides builds select section' do
+ expect(page).to have_selector('.builds-feature', visible: false)
+ end
+ end
+ end
end
context 'as master' do
@@ -36,7 +68,7 @@ feature 'Visibility settings', :js do
visit edit_project_path(project)
end
- scenario 'project visibility is locked' do
+ it 'project visibility is locked' do
visibility_select_container = find('.project-visibility-setting')
expect(visibility_select_container).to have_selector 'select[name="project[visibility_level]"]:disabled'
diff --git a/spec/features/projects/developer_views_empty_project_instructions_spec.rb b/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb
index bf55917bf4c..8803b5222be 100644
--- a/spec/features/projects/developer_views_empty_project_instructions_spec.rb
+++ b/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-feature 'Developer views empty project instructions' do
+feature 'Projects > Show > Developer views empty project instructions' do
let(:project) { create(:project, :empty_repo) }
let(:developer) { create(:user) }
diff --git a/spec/features/projects/main/download_buttons_spec.rb b/spec/features/projects/show/download_buttons_spec.rb
index 81f08e44cf3..254affd4a94 100644
--- a/spec/features/projects/main/download_buttons_spec.rb
+++ b/spec/features/projects/show/download_buttons_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Download buttons in project main page' do
+feature 'Projects > Show > Download buttons' do
given(:user) { create(:user) }
given(:role) { :developer }
given(:status) { 'success' }
diff --git a/spec/features/projects/no_password_spec.rb b/spec/features/projects/show/no_password_spec.rb
index b3b3212556c..b3b3212556c 100644
--- a/spec/features/projects/no_password_spec.rb
+++ b/spec/features/projects/show/no_password_spec.rb
diff --git a/spec/features/projects/redirects_spec.rb b/spec/features/projects/show/redirects_spec.rb
index d1d8ca07035..8d41c547d77 100644
--- a/spec/features/projects/redirects_spec.rb
+++ b/spec/features/projects/show/redirects_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Project redirects' do
+describe 'Projects > Show > Redirects' do
let(:user) { create :user }
let(:public_project) { create :project, :public }
let(:private_project) { create :project, :private }
diff --git a/spec/features/projects/main/rss_spec.rb b/spec/features/projects/show/rss_spec.rb
index 3c98c11b490..d02eaf34533 100644
--- a/spec/features/projects/main/rss_spec.rb
+++ b/spec/features/projects/show/rss_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Project RSS' do
+feature 'Projects > Show > RSS' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:path) { project_path(project) }
diff --git a/spec/features/projects/user_interacts_with_stars_spec.rb b/spec/features/projects/show/user_interacts_with_stars_spec.rb
index d9d2e0ab171..ba28c0e1b8a 100644
--- a/spec/features/projects/user_interacts_with_stars_spec.rb
+++ b/spec/features/projects/show/user_interacts_with_stars_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User interacts with project stars' do
+describe 'Projects > Show > User interacts with project stars' do
let(:project) { create(:project, :public, :repository) }
context 'when user is signed in', :js do
diff --git a/spec/features/projects/show/user_manages_notifications_spec.rb b/spec/features/projects/show/user_manages_notifications_spec.rb
new file mode 100644
index 00000000000..31b105229be
--- /dev/null
+++ b/spec/features/projects/show/user_manages_notifications_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'Projects > Show > User manages notifications', :js do
+ let(:project) { create(:project, :public, :repository) }
+
+ before do
+ sign_in(project.owner)
+ visit project_path(project)
+ end
+
+ it 'changes the notification setting' do
+ first('.notifications-btn').click
+ click_link 'On mention'
+
+ page.within '#notifications-button' do
+ expect(page).to have_content 'On mention'
+ end
+ end
+end
diff --git a/spec/features/projects/show/user_sees_collaboration_links_spec.rb b/spec/features/projects/show/user_sees_collaboration_links_spec.rb
new file mode 100644
index 00000000000..7b3711531c6
--- /dev/null
+++ b/spec/features/projects/show/user_sees_collaboration_links_spec.rb
@@ -0,0 +1,87 @@
+require 'spec_helper'
+
+describe 'Projects > Show > Collaboration links' do
+ let(:project) { create(:project, :repository) }
+ let(:user) { create(:user) }
+
+ before do
+ project.add_developer(user)
+ sign_in(user)
+ end
+
+ it 'shows all the expected links' do
+ visit project_path(project)
+
+ # The navigation bar
+ page.within('.header-new') do
+ aggregate_failures 'dropdown links in the navigation bar' do
+ expect(page).to have_link('New issue')
+ expect(page).to have_link('New merge request')
+ expect(page).to have_link('New snippet', href: new_project_snippet_path(project))
+ end
+ end
+
+ # The project header
+ page.within('.project-home-panel') do
+ aggregate_failures 'dropdown links in the project home panel' do
+ expect(page).to have_link('New issue')
+ expect(page).to have_link('New merge request')
+ expect(page).to have_link('New snippet')
+ expect(page).to have_link('New file')
+ expect(page).to have_link('New branch')
+ expect(page).to have_link('New tag')
+ end
+ end
+
+ # The dropdown above the tree
+ page.within('.repo-breadcrumb') do
+ aggregate_failures 'dropdown links above the repo tree' do
+ expect(page).to have_link('New file')
+ expect(page).to have_link('Upload file')
+ expect(page).to have_link('New directory')
+ expect(page).to have_link('New branch')
+ expect(page).to have_link('New tag')
+ end
+ end
+
+ # The Web IDE
+ expect(page).to have_link('Web IDE')
+ end
+
+ it 'hides the links when the project is archived' do
+ project.update!(archived: true)
+
+ visit project_path(project)
+
+ page.within('.header-new') do
+ aggregate_failures 'dropdown links' do
+ expect(page).not_to have_link('New issue')
+ expect(page).not_to have_link('New merge request')
+ expect(page).not_to have_link('New snippet', href: new_project_snippet_path(project))
+ end
+ end
+
+ page.within('.project-home-panel') do
+ aggregate_failures 'dropdown links' do
+ expect(page).not_to have_link('New issue')
+ expect(page).not_to have_link('New merge request')
+ expect(page).not_to have_link('New snippet')
+ expect(page).not_to have_link('New file')
+ expect(page).not_to have_link('New branch')
+ expect(page).not_to have_link('New tag')
+ end
+ end
+
+ page.within('.repo-breadcrumb') do
+ aggregate_failures 'dropdown links' do
+ expect(page).not_to have_link('New file')
+ expect(page).not_to have_link('Upload file')
+ expect(page).not_to have_link('New directory')
+ expect(page).not_to have_link('New branch')
+ expect(page).not_to have_link('New tag')
+ end
+ end
+
+ expect(page).not_to have_link('Web IDE')
+ end
+end
diff --git a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb
new file mode 100644
index 00000000000..aa23bef6fd8
--- /dev/null
+++ b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe 'Projects > Show > User sees a deletion failure message' do
+ let(:project) { create(:project, :empty_repo, pending_delete: true) }
+
+ before do
+ sign_in(project.owner)
+ end
+
+ it 'shows error message if deletion for project fails' do
+ project.update_attributes(delete_error: "Something went wrong", pending_delete: false)
+
+ visit project_path(project)
+
+ expect(page).to have_selector('.project-deletion-failed-message')
+ expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}")
+ end
+end
diff --git a/spec/features/projects/user_views_details_spec.rb b/spec/features/projects/show/user_sees_git_instructions_spec.rb
index ffc063654cd..9a82fee1b5d 100644
--- a/spec/features/projects/user_views_details_spec.rb
+++ b/spec/features/projects/show/user_sees_git_instructions_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User views details' do
+describe 'Projects > Show > User sees Git instructions' do
set(:user) { create(:user) }
shared_examples_for 'redirects to the sign in page' do
@@ -9,6 +9,16 @@ describe 'User views details' do
end
end
+ shared_examples_for 'shows details of empty project with no repo' do
+ it 'shows Git command line instructions' do
+ click_link 'Create empty repository'
+
+ page.within '.empty_wrapper' do
+ expect(page).to have_content('Command line instructions')
+ end
+ end
+ end
+
shared_examples_for 'shows details of empty project' do
let(:user_has_ssh_key) { false }
@@ -36,6 +46,17 @@ describe 'User views details' do
end
context 'when project is public' do
+ context 'when project has no repo' do
+ set(:project) { create(:project, :public) }
+
+ before do
+ sign_in(project.owner)
+ visit project_path(project)
+ end
+
+ include_examples 'shows details of empty project with no repo'
+ end
+
context 'when project is empty' do
set(:project) { create(:project_empty_repo, :public) }
diff --git a/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb b/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb
new file mode 100644
index 00000000000..e277bfb8011
--- /dev/null
+++ b/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe 'Projects > Show > User sees last commit CI status' do
+ set(:project) { create(:project, :repository, :public) }
+
+ it 'shows the project README', :js do
+ project.enable_ci
+ pipeline = create(:ci_pipeline, project: project, sha: project.commit.sha, ref: 'master')
+ pipeline.skip
+
+ visit project_path(project)
+
+ page.within '.blob-commit-info' do
+ expect(page).to have_content(project.commit.sha[0..6])
+ expect(page).to have_link('Commit: skipped')
+ end
+ end
+end
diff --git a/spec/features/projects/show/user_sees_readme_spec.rb b/spec/features/projects/show/user_sees_readme_spec.rb
new file mode 100644
index 00000000000..d80606c1c23
--- /dev/null
+++ b/spec/features/projects/show/user_sees_readme_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe 'Projects > Show > User sees README' do
+ set(:user) { create(:user) }
+
+ set(:project) { create(:project, :repository, :public) }
+
+ it 'shows the project README', :js do
+ visit project_path(project)
+ wait_for_requests
+
+ page.within('.readme-holder') do
+ expect(page).to have_content 'testme'
+ end
+ end
+end
diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
new file mode 100644
index 00000000000..a906fa20233
--- /dev/null
+++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
@@ -0,0 +1,318 @@
+require 'spec_helper'
+
+describe 'Projects > Show > User sees setup shortcut buttons' do
+ # For "New file", "Add License" functionality,
+ # see spec/features/projects/files/project_owner_creates_license_file_spec.rb
+ # see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
+
+ let(:user) { create(:user) }
+
+ describe 'empty project' do
+ let(:project) { create(:project, :public, :empty_repo) }
+ let(:presenter) { project.present(current_user: user) }
+
+ describe 'as a normal user' do
+ before do
+ sign_in(user)
+
+ visit project_path(project)
+ end
+
+ it 'no Auto DevOps button if can not manage pipelines' do
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Enable Auto DevOps')
+ expect(page).not_to have_link('Auto DevOps enabled')
+ end
+ end
+
+ it '"Auto DevOps enabled" button not linked' do
+ project.create_auto_devops!(enabled: true)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).to have_text('Auto DevOps enabled')
+ end
+ end
+ end
+
+ describe 'as a master' do
+ before do
+ project.add_master(user)
+ sign_in(user)
+
+ visit project_path(project)
+ end
+
+ it '"New file" button linked to new file page' do
+ page.within('.project-stats') do
+ expect(page).to have_link('New file', href: project_new_blob_path(project, project.default_branch || 'master'))
+ end
+ end
+
+ it '"Add Readme" button linked to new file populated for a readme' do
+ page.within('.project-stats') do
+ expect(page).to have_link('Add Readme', href: presenter.add_readme_path)
+ end
+ end
+
+ it '"Add License" button linked to new file populated for a license' do
+ page.within('.project-stats') do
+ expect(page).to have_link('Add License', href: presenter.add_license_path)
+ end
+ end
+
+ describe 'Auto DevOps button' do
+ it '"Enable Auto DevOps" button linked to settings page' do
+ page.within('.project-stats') do
+ expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
+ end
+ end
+
+ it '"Auto DevOps enabled" anchor linked to settings page' do
+ project.create_auto_devops!(enabled: true)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
+ end
+ end
+ end
+
+ describe 'Kubernetes cluster button' do
+ it '"Add Kubernetes cluster" button linked to clusters page' do
+ page.within('.project-stats') do
+ expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
+ end
+ end
+
+ it '"Kubernetes cluster" anchor linked to cluster page' do
+ cluster = create(:cluster, :provided_by_gcp, projects: [project])
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
+ end
+ end
+ end
+ end
+ end
+
+ describe 'populated project' do
+ let(:project) { create(:project, :public, :repository) }
+ let(:presenter) { project.present(current_user: user) }
+
+ describe 'as a normal user' do
+ before do
+ sign_in(user)
+
+ visit project_path(project)
+ end
+
+ it 'no Auto DevOps button if can not manage pipelines' do
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Enable Auto DevOps')
+ expect(page).not_to have_link('Auto DevOps enabled')
+ end
+ end
+
+ it '"Auto DevOps enabled" button not linked' do
+ project.create_auto_devops!(enabled: true)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).to have_text('Auto DevOps enabled')
+ end
+ end
+
+ it 'no Kubernetes cluster button if can not manage clusters' do
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Add Kubernetes cluster')
+ expect(page).not_to have_link('Kubernetes configured')
+ end
+ end
+ end
+
+ describe 'as a master' do
+ before do
+ allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false)
+ project.add_master(user)
+ sign_in(user)
+
+ visit project_path(project)
+ end
+
+ it 'no "Add Changelog" button if the project already has a changelog' do
+ expect(project.repository.changelog).not_to be_nil
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Add Changelog')
+ end
+ end
+
+ it 'no "Add License" button if the project already has a license' do
+ expect(project.repository.license_blob).not_to be_nil
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Add License')
+ end
+ end
+
+ it 'no "Add Contribution guide" button if the project already has a contribution guide' do
+ expect(project.repository.contribution_guide).not_to be_nil
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Add Contribution guide')
+ end
+ end
+
+ describe 'GitLab CI configuration button' do
+ it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do
+ expect(project.repository.gitlab_ci_yml).to be_nil
+
+ page.within('.project-stats') do
+ expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path)
+ end
+ end
+
+ it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do
+ Files::CreateService.new(
+ project,
+ project.creator,
+ start_branch: 'master',
+ branch_name: 'master',
+ commit_message: "Add .gitlab-ci.yml",
+ file_path: '.gitlab-ci.yml',
+ file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ ).execute
+
+ expect(project.repository.gitlab_ci_yml).not_to be_nil
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Set up CI/CD')
+ end
+ end
+
+ it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do
+ project.create_auto_devops!(enabled: true)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Set up CI/CD')
+ end
+ end
+ end
+
+ describe 'Auto DevOps button' do
+ it '"Enable Auto DevOps" button linked to settings page' do
+ page.within('.project-stats') do
+ expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
+ end
+ end
+
+ it '"Enable Auto DevOps" button linked to settings page' do
+ project.create_auto_devops!(enabled: true)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
+ end
+ end
+
+ it 'no Auto DevOps button if Auto DevOps callout is shown' do
+ allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true)
+
+ visit project_path(project)
+
+ expect(page).to have_selector('.js-autodevops-banner')
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Enable Auto DevOps')
+ expect(page).not_to have_link('Auto DevOps enabled')
+ end
+ end
+
+ it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do
+ Files::CreateService.new(
+ project,
+ project.creator,
+ start_branch: 'master',
+ branch_name: 'master',
+ commit_message: "Add .gitlab-ci.yml",
+ file_path: '.gitlab-ci.yml',
+ file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ ).execute
+
+ expect(project.repository.gitlab_ci_yml).not_to be_nil
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Enable Auto DevOps')
+ expect(page).not_to have_link('Auto DevOps enabled')
+ end
+ end
+ end
+
+ describe 'Kubernetes cluster button' do
+ it '"Add Kubernetes cluster" button linked to clusters page' do
+ page.within('.project-stats') do
+ expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
+ end
+ end
+
+ it '"Kubernetes cluster" button linked to cluster page' do
+ cluster = create(:cluster, :provided_by_gcp, projects: [project])
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
+ end
+ end
+ end
+
+ describe '"Set up Koding" button' do
+ it 'no "Set up Koding" button if Koding disabled' do
+ stub_application_setting(koding_enabled?: false)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Set up Koding')
+ end
+ end
+
+ it 'no "Set up Koding" button if the project already has a .koding.yml' do
+ stub_application_setting(koding_enabled?: true)
+ allow(Gitlab::CurrentSettings.current_application_settings).to receive(:koding_url).and_return('http://koding.example.com')
+ expect(project.repository.changelog).not_to be_nil
+ allow_any_instance_of(Repository).to receive(:koding_yml).and_return(project.repository.changelog)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).not_to have_link('Set up Koding')
+ end
+ end
+
+ it '"Set up Koding" button linked to new file populated for a .koding.yml' do
+ stub_application_setting(koding_enabled?: true)
+
+ visit project_path(project)
+
+ page.within('.project-stats') do
+ expect(page).to have_link('Set up Koding', href: presenter.add_koding_stack_path)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/show_project_spec.rb b/spec/features/projects/show_project_spec.rb
deleted file mode 100644
index e4f13e6cab7..00000000000
--- a/spec/features/projects/show_project_spec.rb
+++ /dev/null
@@ -1,359 +0,0 @@
-require 'spec_helper'
-
-describe 'Project show page', :feature do
- include DropzoneHelper
-
- context 'when project pending delete' do
- let(:project) { create(:project, :empty_repo, pending_delete: true) }
-
- before do
- sign_in(project.owner)
- end
-
- it 'shows error message if deletion for project fails' do
- project.update_attributes(delete_error: "Something went wrong", pending_delete: false)
-
- visit project_path(project)
-
- expect(page).to have_selector('.project-deletion-failed-message')
- expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}")
- end
- end
-
- describe 'stat button existence' do
- # For "New file", "Add License" functionality,
- # see spec/features/projects/files/project_owner_creates_license_file_spec.rb
- # see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
-
- let(:user) { create(:user) }
-
- describe 'empty project' do
- let(:project) { create(:project, :public, :empty_repo) }
- let(:presenter) { project.present(current_user: user) }
-
- describe 'as a normal user' do
- before do
- sign_in(user)
-
- visit project_path(project)
- end
-
- it 'no Auto DevOps button if can not manage pipelines' do
- page.within('.project-stats') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
- end
- end
-
- it '"Auto DevOps enabled" button not linked' do
- project.create_auto_devops!(enabled: true)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).to have_text('Auto DevOps enabled')
- end
- end
- end
-
- describe 'as a master' do
- before do
- project.add_master(user)
- sign_in(user)
-
- visit project_path(project)
- end
-
- it '"New file" button linked to new file page' do
- page.within('.project-stats') do
- expect(page).to have_link('New file', href: project_new_blob_path(project, project.default_branch || 'master'))
- end
- end
-
- it '"Add Readme" button linked to new file populated for a readme' do
- page.within('.project-stats') do
- expect(page).to have_link('Add Readme', href: presenter.add_readme_path)
- end
- end
-
- it '"Add License" button linked to new file populated for a license' do
- page.within('.project-stats') do
- expect(page).to have_link('Add License', href: presenter.add_license_path)
- end
- end
-
- describe 'Auto DevOps button' do
- it '"Enable Auto DevOps" button linked to settings page' do
- page.within('.project-stats') do
- expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
- end
- end
-
- it '"Auto DevOps enabled" anchor linked to settings page' do
- project.create_auto_devops!(enabled: true)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
- end
- end
- end
-
- describe 'Kubernetes cluster button' do
- it '"Add Kubernetes cluster" button linked to clusters page' do
- page.within('.project-stats') do
- expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
- end
- end
-
- it '"Kubernetes cluster" anchor linked to cluster page' do
- cluster = create(:cluster, :provided_by_gcp, projects: [project])
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
- end
- end
- end
- end
- end
-
- describe 'populated project' do
- let(:project) { create(:project, :public, :repository) }
- let(:presenter) { project.present(current_user: user) }
-
- describe 'as a normal user' do
- before do
- sign_in(user)
-
- visit project_path(project)
- end
-
- it 'no Auto DevOps button if can not manage pipelines' do
- page.within('.project-stats') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
- end
- end
-
- it '"Auto DevOps enabled" button not linked' do
- project.create_auto_devops!(enabled: true)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).to have_text('Auto DevOps enabled')
- end
- end
-
- it 'no Kubernetes cluster button if can not manage clusters' do
- page.within('.project-stats') do
- expect(page).not_to have_link('Add Kubernetes cluster')
- expect(page).not_to have_link('Kubernetes configured')
- end
- end
- end
-
- describe 'as a master' do
- before do
- allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false)
- project.add_master(user)
- sign_in(user)
-
- visit project_path(project)
- end
-
- it 'no "Add Changelog" button if the project already has a changelog' do
- expect(project.repository.changelog).not_to be_nil
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Add Changelog')
- end
- end
-
- it 'no "Add License" button if the project already has a license' do
- expect(project.repository.license_blob).not_to be_nil
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Add License')
- end
- end
-
- it 'no "Add Contribution guide" button if the project already has a contribution guide' do
- expect(project.repository.contribution_guide).not_to be_nil
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Add Contribution guide')
- end
- end
-
- describe 'GitLab CI configuration button' do
- it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do
- expect(project.repository.gitlab_ci_yml).to be_nil
-
- page.within('.project-stats') do
- expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path)
- end
- end
-
- it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do
- Files::CreateService.new(
- project,
- project.creator,
- start_branch: 'master',
- branch_name: 'master',
- commit_message: "Add .gitlab-ci.yml",
- file_path: '.gitlab-ci.yml',
- file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
- ).execute
-
- expect(project.repository.gitlab_ci_yml).not_to be_nil
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Set up CI/CD')
- end
- end
-
- it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do
- project.create_auto_devops!(enabled: true)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Set up CI/CD')
- end
- end
- end
-
- describe 'Auto DevOps button' do
- it '"Enable Auto DevOps" button linked to settings page' do
- page.within('.project-stats') do
- expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
- end
- end
-
- it '"Enable Auto DevOps" button linked to settings page' do
- project.create_auto_devops!(enabled: true)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
- end
- end
-
- it 'no Auto DevOps button if Auto DevOps callout is shown' do
- allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true)
-
- visit project_path(project)
-
- expect(page).to have_selector('.js-autodevops-banner')
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
- end
- end
-
- it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do
- Files::CreateService.new(
- project,
- project.creator,
- start_branch: 'master',
- branch_name: 'master',
- commit_message: "Add .gitlab-ci.yml",
- file_path: '.gitlab-ci.yml',
- file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
- ).execute
-
- expect(project.repository.gitlab_ci_yml).not_to be_nil
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
- end
- end
- end
-
- describe 'Kubernetes cluster button' do
- it '"Add Kubernetes cluster" button linked to clusters page' do
- page.within('.project-stats') do
- expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
- end
- end
-
- it '"Kubernetes cluster" button linked to cluster page' do
- cluster = create(:cluster, :provided_by_gcp, projects: [project])
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
- end
- end
- end
-
- describe '"Set up Koding" button' do
- it 'no "Set up Koding" button if Koding disabled' do
- stub_application_setting(koding_enabled?: false)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Set up Koding')
- end
- end
-
- it 'no "Set up Koding" button if the project already has a .koding.yml' do
- stub_application_setting(koding_enabled?: true)
- allow(Gitlab::CurrentSettings.current_application_settings).to receive(:koding_url).and_return('http://koding.example.com')
- expect(project.repository.changelog).not_to be_nil
- allow_any_instance_of(Repository).to receive(:koding_yml).and_return(project.repository.changelog)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).not_to have_link('Set up Koding')
- end
- end
-
- it '"Set up Koding" button linked to new file populated for a .koding.yml' do
- stub_application_setting(koding_enabled?: true)
-
- visit project_path(project)
-
- page.within('.project-stats') do
- expect(page).to have_link('Set up Koding', href: presenter.add_koding_stack_path)
- end
- end
- end
- end
- end
- end
-
- describe 'dropzone', :js do
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
-
- before do
- project.add_master(user)
- sign_in(user)
-
- visit project_path(project)
- end
-
- it 'can upload files' do
- find('.add-to-tree').click
- click_link 'Upload file'
- drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
-
- expect(find('.dz-filename')).to have_content('doc_sample.txt')
- end
- end
-end
diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb
index 3466a3dfb77..2388feeb980 100644
--- a/spec/features/projects/snippets/create_snippet_spec.rb
+++ b/spec/features/projects/snippets/create_snippet_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-feature 'Create Snippet', :js do
+describe 'Projects > Snippets > Create Snippet', :js do
include DropzoneHelper
let(:user) { create(:user) }
diff --git a/spec/features/projects/snippets/show_spec.rb b/spec/features/projects/snippets/show_spec.rb
index 216f2af7c88..004ac55b656 100644
--- a/spec/features/projects/snippets/show_spec.rb
+++ b/spec/features/projects/snippets/show_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Project snippet', :js do
+describe 'Projects > Snippets > Project snippet', :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:snippet) { create(:project_snippet, project: project, file_name: file_name, content: content) }
diff --git a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb
index 1bd2098af6d..01cf9740d1f 100644
--- a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb
+++ b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User comments on a snippet', :js do
+describe 'Projects > Snippets > User comments on a snippet', :js do
let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) }
@@ -22,4 +22,16 @@ describe 'User comments on a snippet', :js do
expect(page).to have_content('Good snippet!')
end
+
+ it 'should have autocomplete' do
+ find('#note_note').native.send_keys('')
+ fill_in 'note[note]', with: '@'
+
+ expect(page).to have_selector('.atwho-view')
+ end
+
+ it 'should have zen mode' do
+ find('.js-zen-enter').click()
+ expect(page).to have_selector('.fullscreen')
+ end
end
diff --git a/spec/features/projects/snippets/user_deletes_snippet_spec.rb b/spec/features/projects/snippets/user_deletes_snippet_spec.rb
index ca5f7981c33..e64837ad59e 100644
--- a/spec/features/projects/snippets/user_deletes_snippet_spec.rb
+++ b/spec/features/projects/snippets/user_deletes_snippet_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User deletes a snippet' do
+describe 'Projects > Snippets > User deletes a snippet' do
let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) }
diff --git a/spec/features/projects/snippets/user_updates_snippet_spec.rb b/spec/features/projects/snippets/user_updates_snippet_spec.rb
index 09a390443cf..eaedbbf32b6 100644
--- a/spec/features/projects/snippets/user_updates_snippet_spec.rb
+++ b/spec/features/projects/snippets/user_updates_snippet_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'User updates a snippet' do
+describe 'Projects > Snippets > User updates a snippet' do
let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) }
diff --git a/spec/features/projects/snippets/user_views_snippets_spec.rb b/spec/features/projects/snippets/user_views_snippets_spec.rb
index e9992e00ca8..376b76e0001 100644
--- a/spec/features/projects/snippets/user_views_snippets_spec.rb
+++ b/spec/features/projects/snippets/user_views_snippets_spec.rb
@@ -1,9 +1,10 @@
require 'spec_helper'
-describe 'User views snippets' do
+describe 'Projects > Snippets > User views snippets' do
let(:project) { create(:project) }
let!(:project_snippet) { create(:project_snippet, project: project, author: user) }
let!(:snippet) { create(:snippet, author: user) }
+ let(:snippets) { [project_snippet, snippet] } # Used by the shared examples
let(:user) { create(:user) }
before do
@@ -13,6 +14,17 @@ describe 'User views snippets' do
visit(project_snippets_path(project))
end
+ context 'pagination' do
+ before do
+ create(:project_snippet, project: project, author: user)
+ allow(Snippet).to receive(:default_per_page).and_return(1)
+
+ visit project_snippets_path(project)
+ end
+
+ it_behaves_like 'paginated snippets'
+ end
+
it 'shows snippets' do
expect(page).to have_content(project_snippet.title)
expect(page).not_to have_content(snippet.title)
diff --git a/spec/features/projects/snippets_spec.rb b/spec/features/projects/snippets_spec.rb
deleted file mode 100644
index 0fa7ca9afd4..00000000000
--- a/spec/features/projects/snippets_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'spec_helper'
-
-describe 'Project snippets', :js do
- context 'when the project has snippets' do
- let(:project) { create(:project, :public) }
- let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) }
- let!(:other_snippet) { create(:project_snippet) }
-
- context 'pagination' do
- before do
- allow(Snippet).to receive(:default_per_page).and_return(1)
-
- visit project_snippets_path(project)
- end
-
- it_behaves_like 'paginated snippets'
- end
-
- context 'list content' do
- it 'contains all project snippets' do
- visit project_snippets_path(project)
-
- expect(page).to have_selector('.snippet-row', count: 2)
-
- expect(page).to have_content(snippets[0].title)
- expect(page).to have_content(snippets[1].title)
- end
- end
-
- context 'when submitting a note' do
- before do
- sign_in(create(:admin))
- visit project_snippet_path(project, snippets[0])
- end
-
- it 'should have autocomplete' do
- find('#note_note').native.send_keys('')
- fill_in 'note[note]', with: '@'
-
- expect(page).to have_selector('.atwho-view')
- end
-
- it 'should have zen mode' do
- find('.js-zen-enter').click()
- expect(page).to have_selector('.fullscreen')
- end
- end
- end
-end
diff --git a/spec/features/projects/user_sees_sidebar_spec.rb b/spec/features/projects/user_sees_sidebar_spec.rb
new file mode 100644
index 00000000000..cf80517b934
--- /dev/null
+++ b/spec/features/projects/user_sees_sidebar_spec.rb
@@ -0,0 +1,106 @@
+require 'spec_helper'
+
+describe 'Projects > User sees sidebar' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :private, public_builds: false, namespace: user.namespace) }
+
+ context 'as owner' do
+ before do
+ sign_in(user)
+ end
+
+ context 'when snippets are disabled' do
+ before do
+ project.project_feature.update_attribute('snippets_access_level', ProjectFeature::DISABLED)
+ end
+
+ it 'does not display a "Snippets" link' do
+ visit project_path(project)
+
+ within('.nav-sidebar') do
+ expect(page).not_to have_content 'Snippets'
+ end
+ end
+ end
+ end
+
+ context 'as guest' do
+ let(:guest) { create(:user) }
+
+ before do
+ project.add_guest(guest)
+
+ sign_in(guest)
+ end
+
+ it 'shows allowed tabs only' do
+ visit project_path(project)
+
+ within('.nav-sidebar') do
+ expect(page).to have_content 'Overview'
+ expect(page).to have_content 'Issues'
+ expect(page).to have_content 'Wiki'
+
+ expect(page).not_to have_content 'Repository'
+ expect(page).not_to have_content 'CI / CD'
+ expect(page).not_to have_content 'Merge Requests'
+ end
+ end
+
+ it 'does not show fork button' do
+ visit project_path(project)
+
+ within('.count-buttons') do
+ expect(page).not_to have_link 'Fork'
+ end
+ end
+
+ it 'does not show clone path' do
+ visit project_path(project)
+
+ within('.project-repo-buttons') do
+ expect(page).not_to have_selector '.project-clone-holder'
+ end
+ end
+
+ describe 'project landing page' do
+ before do
+ project.project_feature.update!(
+ issues_access_level: ProjectFeature::DISABLED,
+ wiki_access_level: ProjectFeature::DISABLED
+ )
+ end
+
+ it 'does not show the project file list landing page' do
+ visit project_path(project)
+
+ expect(page).not_to have_selector '.project-stats'
+ expect(page).not_to have_selector '.project-last-commit'
+ expect(page).not_to have_selector '.project-show-files'
+ expect(page).to have_selector '.project-show-customize_workflow'
+ end
+
+ it 'shows the customize workflow when issues and wiki are disabled' do
+ visit project_path(project)
+
+ expect(page).to have_selector '.project-show-customize_workflow'
+ end
+
+ it 'shows the wiki when enabled' do
+ project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE)
+
+ visit project_path(project)
+
+ expect(page).to have_selector '.project-show-wiki'
+ end
+
+ it 'shows the issues when enabled' do
+ project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
+
+ visit project_path(project)
+
+ expect(page).to have_selector '.issues-list'
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/user_transfers_a_project_spec.rb b/spec/features/projects/user_transfers_a_project_spec.rb
deleted file mode 100644
index 78f72b644ff..00000000000
--- a/spec/features/projects/user_transfers_a_project_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'spec_helper'
-
-feature 'User transfers a project', :js do
- let(:user) { create(:user) }
- let(:project) { create(:project, :repository, namespace: user.namespace) }
-
- before do
- sign_in user
- end
-
- def transfer_project(project, group)
- visit edit_project_path(project)
-
- page.within('.js-project-transfer-form') do
- page.find('.select2-container').click
- end
-
- page.find("div[role='option']", text: group.full_name).click
-
- click_button('Transfer project')
-
- fill_in 'confirm_name_input', with: project.name
-
- click_button 'Confirm'
-
- wait_for_requests
- end
-
- it 'allows transferring a project to a subgroup of a namespace' do
- group = create(:group)
- group.add_owner(user)
-
- transfer_project(project, group)
-
- expect(project.reload.namespace).to eq(group)
- end
-
- context 'when nested groups are available', :nested_groups do
- it 'allows transferring a project to a subgroup' do
- parent = create(:group)
- parent.add_owner(user)
- subgroup = create(:group, parent: parent)
-
- transfer_project(project, subgroup)
-
- expect(project.reload.namespace).to eq(subgroup)
- end
- end
-end
diff --git a/spec/features/projects/user_uses_shortcuts_spec.rb b/spec/features/projects/user_uses_shortcuts_spec.rb
index fb0d8c766fe..47c5a8161d9 100644
--- a/spec/features/projects/user_uses_shortcuts_spec.rb
+++ b/spec/features/projects/user_uses_shortcuts_spec.rb
@@ -11,12 +11,12 @@ describe 'User uses shortcuts', :js do
visit(project_path(project))
end
- context 'when navigating to the Overview pages' do
+ context 'when navigating to the Project pages' do
it 'redirects to the details page' do
find('body').native.send_key('g')
find('body').native.send_key('p')
- expect(page).to have_active_navigation('Overview')
+ expect(page).to have_active_navigation('Project')
expect(page).to have_active_sub_navigation('Details')
end
@@ -24,7 +24,7 @@ describe 'User uses shortcuts', :js do
find('body').native.send_key('g')
find('body').native.send_key('e')
- expect(page).to have_active_navigation('Overview')
+ expect(page).to have_active_navigation('Project')
expect(page).to have_active_sub_navigation('Activity')
end
end
diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb
index bc75dc5d19b..9e10bfb2adc 100644
--- a/spec/features/users/login_spec.rb
+++ b/spec/features/users/login_spec.rb
@@ -392,7 +392,7 @@ feature 'Login' do
end
def ensure_one_active_tab
- expect(page).to have_selector('.nav-tabs > li.active', count: 1)
+ expect(page).to have_selector('ul.new-session-tabs > li.active', count: 1)
end
def ensure_one_active_pane
diff --git a/spec/finders/merge_request_target_project_finder_spec.rb b/spec/finders/merge_request_target_project_finder_spec.rb
index c81bfd7932c..f302cf80ce8 100644
--- a/spec/finders/merge_request_target_project_finder_spec.rb
+++ b/spec/finders/merge_request_target_project_finder_spec.rb
@@ -19,6 +19,12 @@ describe MergeRequestTargetProjectFinder do
expect(finder.execute).to contain_exactly(forked_project)
end
+
+ it 'does not contain archived projects' do
+ base_project.update!(archived: true)
+
+ expect(finder.execute).to contain_exactly(other_fork, forked_project)
+ end
end
context 'public projects' do
diff --git a/spec/fixtures/big-image.png b/spec/fixtures/big-image.png
new file mode 100644
index 00000000000..a333363ac36
--- /dev/null
+++ b/spec/fixtures/big-image.png
Binary files differ
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index aeef5352333..8bb2e234e9a 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -96,13 +96,32 @@ describe IssuesHelper do
describe '#award_state_class' do
let!(:upvote) { create(:award_emoji) }
+ let(:awardable) { upvote.awardable }
+ let(:user) { upvote.user }
+
+ before do
+ allow(helper).to receive(:can?) do |*args|
+ Ability.allowed?(*args)
+ end
+ end
it "returns disabled string for unauthenticated user" do
- expect(award_state_class(AwardEmoji.all, nil)).to eq("disabled")
+ expect(helper.award_state_class(awardable, AwardEmoji.all, nil)).to eq("disabled")
+ end
+
+ it "returns disabled for a user that does not have access to the awardable" do
+ expect(helper.award_state_class(awardable, AwardEmoji.all, build(:user))).to eq("disabled")
end
it "returns active string for author" do
- expect(award_state_class(AwardEmoji.all, upvote.user)).to eq("active")
+ expect(helper.award_state_class(awardable, AwardEmoji.all, upvote.user)).to eq("active")
+ end
+
+ it "is blank for a user that has access to the awardable" do
+ user = build(:user)
+ expect(helper).to receive(:can?).with(user, :award_emoji, awardable).and_return(true)
+
+ expect(helper.award_state_class(awardable, AwardEmoji.all, user)).to be_blank
end
end
@@ -144,4 +163,26 @@ describe IssuesHelper do
end
end
end
+
+ describe '#show_new_issue_link?' do
+ before do
+ allow(helper).to receive(:current_user)
+ end
+
+ it 'is false when no project there is no project' do
+ expect(helper.show_new_issue_link?(nil)).to be_falsey
+ end
+
+ it 'is true when there is a project and no logged in user' do
+ expect(helper.show_new_issue_link?(build(:project))).to be_truthy
+ end
+
+ it 'is true when the current user does not have access to the project' do
+ project = build(:project)
+ allow(helper).to receive(:current_user).and_return(project.owner)
+
+ expect(helper).to receive(:can?).with(project.owner, :create_issue, project).and_return(true)
+ expect(helper.show_new_issue_link?(project)).to be_truthy
+ end
+ end
end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index ce96e90e2d7..46c55da24f8 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -322,74 +322,6 @@ describe ProjectsHelper do
end
end
- describe "#project_feature_access_select" do
- let(:project) { create(:project, :public) }
- let(:user) { create(:user) }
-
- context "when project is internal or public" do
- it "shows all options" do
- helper.instance_variable_set(:@project, project)
- result = helper.project_feature_access_select(:issues_access_level)
- expect(result).to include("Disabled")
- expect(result).to include("Only team members")
- expect(result).to include("Everyone with access")
- end
- end
-
- context "when project is private" do
- before do
- project.update_attributes(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- end
-
- it "shows only allowed options" do
- helper.instance_variable_set(:@project, project)
- result = helper.project_feature_access_select(:issues_access_level)
- expect(result).to include("Disabled")
- expect(result).to include("Only team members")
- expect(result).to have_selector('option[disabled]', text: "Everyone with access")
- end
- end
-
- context "when project moves from public to private" do
- before do
- project.update_attributes(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- end
-
- it "shows the highest allowed level selected" do
- helper.instance_variable_set(:@project, project)
- result = helper.project_feature_access_select(:issues_access_level)
-
- expect(result).to include("Disabled")
- expect(result).to include("Only team members")
- expect(result).to have_selector('option[disabled]', text: "Everyone with access")
- expect(result).to have_selector('option[selected]', text: "Only team members")
- end
- end
- end
-
- describe "#visibility_select_options" do
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
-
- before do
- allow(helper).to receive(:current_user).and_return(user)
-
- stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
- end
-
- it "does not include the Public restricted level" do
- expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).not_to include('Public')
- end
-
- it "includes the Internal level" do
- expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).to include('Internal')
- end
-
- it "includes the Private level" do
- expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).to include('Private')
- end
- end
-
describe '#get_project_nav_tabs' do
let(:project) { create(:project) }
let(:user) { create(:user) }
diff --git a/spec/javascripts/commit/pipelines/pipelines_spec.js b/spec/javascripts/commit/pipelines/pipelines_spec.js
index 0afe09d87bc..53820770f3f 100644
--- a/spec/javascripts/commit/pipelines/pipelines_spec.js
+++ b/spec/javascripts/commit/pipelines/pipelines_spec.js
@@ -1,113 +1,82 @@
-import _ from 'underscore';
import Vue from 'vue';
+import MockAdapter from 'axios-mock-adapter';
+import axios from '~/lib/utils/axios_utils';
import pipelinesTable from '~/commit/pipelines/pipelines_table.vue';
+import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('Pipelines table in Commits and Merge requests', () => {
const jsonFixtureName = 'pipelines/pipelines.json';
let pipeline;
let PipelinesTable;
+ let mock;
+ let vm;
preloadFixtures(jsonFixtureName);
beforeEach(() => {
+ mock = new MockAdapter(axios);
+
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
PipelinesTable = Vue.extend(pipelinesTable);
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
});
+ afterEach(() => {
+ vm.$destroy();
+ mock.restore();
+ });
+
describe('successful request', () => {
describe('without pipelines', () => {
- const pipelinesEmptyResponse = (request, next) => {
- next(request.respondWith(JSON.stringify([]), {
- status: 200,
- }));
- };
-
beforeEach(function () {
- Vue.http.interceptors.push(pipelinesEmptyResponse);
-
- this.component = new PipelinesTable({
- propsData: {
- endpoint: 'endpoint',
- helpPagePath: 'foo',
- emptyStateSvgPath: 'foo',
- errorStateSvgPath: 'foo',
- autoDevopsHelpPath: 'foo',
- },
- }).$mount();
- });
+ mock.onGet('endpoint.json').reply(200, []);
- afterEach(function () {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, pipelinesEmptyResponse,
- );
- this.component.$destroy();
+ vm = mountComponent(PipelinesTable, {
+ endpoint: 'endpoint.json',
+ helpPagePath: 'foo',
+ emptyStateSvgPath: 'foo',
+ errorStateSvgPath: 'foo',
+ autoDevopsHelpPath: 'foo',
+ });
});
it('should render the empty state', function (done) {
setTimeout(() => {
- expect(this.component.$el.querySelector('.empty-state')).toBeDefined();
- expect(this.component.$el.querySelector('.realtime-loading')).toBe(null);
- expect(this.component.$el.querySelector('.js-pipelines-error-state')).toBe(null);
+ expect(vm.$el.querySelector('.empty-state')).toBeDefined();
+ expect(vm.$el.querySelector('.realtime-loading')).toBe(null);
+ expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null);
done();
- }, 1);
+ }, 0);
});
});
describe('with pipelines', () => {
- const pipelinesResponse = (request, next) => {
- next(request.respondWith(JSON.stringify([pipeline]), {
- status: 200,
- }));
- };
-
beforeEach(() => {
- Vue.http.interceptors.push(pipelinesResponse);
-
- this.component = new PipelinesTable({
- propsData: {
- endpoint: 'endpoint',
- helpPagePath: 'foo',
- emptyStateSvgPath: 'foo',
- errorStateSvgPath: 'foo',
- autoDevopsHelpPath: 'foo',
- },
- }).$mount();
- });
-
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, pipelinesResponse,
- );
- this.component.$destroy();
+ mock.onGet('endpoint.json').reply(200, [pipeline]);
+ vm = mountComponent(PipelinesTable, {
+ endpoint: 'endpoint.json',
+ helpPagePath: 'foo',
+ emptyStateSvgPath: 'foo',
+ errorStateSvgPath: 'foo',
+ autoDevopsHelpPath: 'foo',
+ });
});
it('should render a table with the received pipelines', (done) => {
setTimeout(() => {
- expect(this.component.$el.querySelectorAll('.ci-table .commit').length).toEqual(1);
- expect(this.component.$el.querySelector('.realtime-loading')).toBe(null);
- expect(this.component.$el.querySelector('.empty-state')).toBe(null);
- expect(this.component.$el.querySelector('.js-pipelines-error-state')).toBe(null);
+ expect(vm.$el.querySelectorAll('.ci-table .commit').length).toEqual(1);
+ expect(vm.$el.querySelector('.realtime-loading')).toBe(null);
+ expect(vm.$el.querySelector('.empty-state')).toBe(null);
+ expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null);
done();
}, 0);
});
});
describe('pipeline badge counts', () => {
- const pipelinesResponse = (request, next) => {
- next(request.respondWith(JSON.stringify([pipeline]), {
- status: 200,
- }));
- };
-
beforeEach(() => {
- Vue.http.interceptors.push(pipelinesResponse);
- });
-
- afterEach(() => {
- Vue.http.interceptors = _.without(Vue.http.interceptors, pipelinesResponse);
- this.component.$destroy();
+ mock.onGet('endpoint.json').reply(200, [pipeline]);
});
it('should receive update-pipelines-count event', (done) => {
@@ -119,54 +88,38 @@ describe('Pipelines table in Commits and Merge requests', () => {
done();
});
- this.component = new PipelinesTable({
- propsData: {
- endpoint: 'endpoint',
- helpPagePath: 'foo',
- emptyStateSvgPath: 'foo',
- errorStateSvgPath: 'foo',
- autoDevopsHelpPath: 'foo',
- },
- }).$mount();
- element.appendChild(this.component.$el);
- });
- });
- });
-
- describe('unsuccessfull request', () => {
- const pipelinesErrorResponse = (request, next) => {
- next(request.respondWith(JSON.stringify([]), {
- status: 500,
- }));
- };
-
- beforeEach(function () {
- Vue.http.interceptors.push(pipelinesErrorResponse);
-
- this.component = new PipelinesTable({
- propsData: {
- endpoint: 'endpoint',
+ vm = mountComponent(PipelinesTable, {
+ endpoint: 'endpoint.json',
helpPagePath: 'foo',
emptyStateSvgPath: 'foo',
errorStateSvgPath: 'foo',
autoDevopsHelpPath: 'foo',
- },
- }).$mount();
+ });
+
+ element.appendChild(vm.$el);
+ });
});
+ });
- afterEach(function () {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, pipelinesErrorResponse,
- );
- this.component.$destroy();
+ describe('unsuccessfull request', () => {
+ beforeEach(() => {
+ mock.onGet('endpoint.json').reply(500, []);
+
+ vm = mountComponent(PipelinesTable, {
+ endpoint: 'endpoint.json',
+ helpPagePath: 'foo',
+ emptyStateSvgPath: 'foo',
+ errorStateSvgPath: 'foo',
+ autoDevopsHelpPath: 'foo',
+ });
});
it('should render error state', function (done) {
setTimeout(() => {
- expect(this.component.$el.querySelector('.js-pipelines-error-state')).toBeDefined();
- expect(this.component.$el.querySelector('.realtime-loading')).toBe(null);
- expect(this.component.$el.querySelector('.js-empty-state')).toBe(null);
- expect(this.component.$el.querySelector('.ci-table')).toBe(null);
+ expect(vm.$el.querySelector('.js-pipelines-error-state')).toBeDefined();
+ expect(vm.$el.querySelector('.realtime-loading')).toBe(null);
+ expect(vm.$el.querySelector('.js-empty-state')).toBe(null);
+ expect(vm.$el.querySelector('.ci-table')).toBe(null);
done();
}, 0);
});
diff --git a/spec/javascripts/fixtures/linked_tabs.html.haml b/spec/javascripts/fixtures/linked_tabs.html.haml
index 2de53188e98..632606e0536 100644
--- a/spec/javascripts/fixtures/linked_tabs.html.haml
+++ b/spec/javascripts/fixtures/linked_tabs.html.haml
@@ -1,4 +1,4 @@
-%ul.nav.nav-tabs.linked-tabs
+%ul.nav.nav-tabs.new-session-tabs.linked-tabs
%li.nav-item
%a.nav-link{ href: 'foo/bar/1', data: { target: 'div#tab1', action: 'tab1', toggle: 'tab' } }
Tab 1
diff --git a/spec/javascripts/fixtures/signin_tabs.html.haml b/spec/javascripts/fixtures/signin_tabs.html.haml
index 12b8d423cbe..2e00fe7865e 100644
--- a/spec/javascripts/fixtures/signin_tabs.html.haml
+++ b/spec/javascripts/fixtures/signin_tabs.html.haml
@@ -1,5 +1,5 @@
-%ul.nav-tabs
+%ul.nav-links.new-session-tabs
+ %li.active
+ %a{ href: '#ldap' } LDAP
%li
- %a.active{ id: 'standard', href: '#standard'} Standard
- %li
- %a{ id: 'ldap', href: '#ldap'} Ldap
+ %a{ href: '#login-pane'} Standard
diff --git a/spec/javascripts/ide/components/repo_editor_spec.js b/spec/javascripts/ide/components/repo_editor_spec.js
index 63a3d2c6cd5..310d222377f 100644
--- a/spec/javascripts/ide/components/repo_editor_spec.js
+++ b/spec/javascripts/ide/components/repo_editor_spec.js
@@ -1,9 +1,12 @@
import Vue from 'vue';
+import MockAdapter from 'axios-mock-adapter';
+import axios from '~/lib/utils/axios_utils';
import store from '~/ide/stores';
import repoEditor from '~/ide/components/repo_editor.vue';
import monacoLoader from '~/ide/monaco_loader';
import Editor from '~/ide/lib/editor';
import { createComponentWithStore } from '../../helpers/vue_mount_component_helper';
+import setTimeoutPromise from '../../helpers/set_timeout_promise_helper';
import { file, resetStore } from '../helpers';
describe('RepoEditor', () => {
@@ -35,7 +38,7 @@ describe('RepoEditor', () => {
resetStore(vm.$store);
- Editor.editorInstance.modelManager.dispose();
+ Editor.editorInstance.dispose();
});
it('renders an ide container', done => {
@@ -79,16 +82,30 @@ describe('RepoEditor', () => {
});
describe('when file is markdown and viewer mode is review', () => {
+ let mock;
+
beforeEach(done => {
+ mock = new MockAdapter(axios);
+
+ vm.file.projectId = 'namespace/project';
vm.file.previewMode = {
id: 'markdown',
previewTitle: 'Preview Markdown',
};
+ vm.file.content = 'testing 123';
vm.$store.state.viewer = 'diff';
+ mock.onPost(/(.*)\/preview_markdown/).reply(200, {
+ body: '<p>testing 123</p>',
+ });
+
vm.$nextTick(done);
});
+ afterEach(() => {
+ mock.restore();
+ });
+
it('renders an Edit and a Preview Tab', done => {
Vue.nextTick(() => {
const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li');
@@ -99,6 +116,26 @@ describe('RepoEditor', () => {
done();
});
});
+
+ it('renders markdown for tempFile', done => {
+ vm.file.tempFile = true;
+ vm.file.path = `${vm.file.path}.md`;
+ vm.$store.state.entries[vm.file.path] = vm.file;
+
+ vm
+ .$nextTick()
+ .then(() => {
+ vm.$el.querySelectorAll('.ide-mode-tabs .nav-links a')[1].click();
+ })
+ .then(setTimeoutPromise)
+ .then(() => {
+ expect(vm.$el.querySelector('.preview-container').innerHTML).toContain(
+ '<p>testing 123</p>',
+ );
+ })
+ .then(done)
+ .catch(done.fail);
+ });
});
describe('when open file is binary and not raw', () => {
diff --git a/spec/javascripts/notes/components/note_actions_spec.js b/spec/javascripts/notes/components/note_actions_spec.js
index ab81aabb992..1dfe890e05e 100644
--- a/spec/javascripts/notes/components/note_actions_spec.js
+++ b/spec/javascripts/notes/components/note_actions_spec.js
@@ -3,7 +3,7 @@ import store from '~/notes/stores';
import noteActions from '~/notes/components/note_actions.vue';
import { userDataMock } from '../mock_data';
-describe('issse_note_actions component', () => {
+describe('issue_note_actions component', () => {
let vm;
let Component;
@@ -24,6 +24,7 @@ describe('issse_note_actions component', () => {
authorId: 26,
canDelete: true,
canEdit: true,
+ canAwardEmoji: true,
canReportAsAbuse: true,
noteId: 539,
reportAbusePath: '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F7%23note_539&user_id=26',
@@ -70,6 +71,7 @@ describe('issse_note_actions component', () => {
authorId: 26,
canDelete: false,
canEdit: false,
+ canAwardEmoji: false,
canReportAsAbuse: false,
noteId: 539,
reportAbusePath: '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F7%23note_539&user_id=26',
diff --git a/spec/javascripts/notes/components/note_awards_list_spec.js b/spec/javascripts/notes/components/note_awards_list_spec.js
index 15995ec5a05..1c30d8691b1 100644
--- a/spec/javascripts/notes/components/note_awards_list_spec.js
+++ b/spec/javascripts/notes/components/note_awards_list_spec.js
@@ -29,6 +29,7 @@ describe('note_awards_list component', () => {
awards: awardsMock,
noteAuthorId: 2,
noteId: 545,
+ canAwardEmoji: true,
toggleAwardPath: '/gitlab-org/gitlab-ce/notes/545/toggle_award_emoji',
},
}).$mount();
@@ -43,14 +44,45 @@ describe('note_awards_list component', () => {
expect(vm.$el.querySelector('.js-awards-block button [data-name="cartwheel_tone3"]')).toBeDefined();
});
- it('should be possible to remove awareded emoji', () => {
+ it('should be possible to remove awarded emoji', () => {
spyOn(vm, 'handleAward').and.callThrough();
+ spyOn(vm, 'toggleAwardRequest').and.callThrough();
vm.$el.querySelector('.js-awards-block button').click();
expect(vm.handleAward).toHaveBeenCalledWith('flag_tz');
+ expect(vm.toggleAwardRequest).toHaveBeenCalled();
});
it('should be possible to add new emoji', () => {
expect(vm.$el.querySelector('.js-add-award')).toBeDefined();
});
+
+ describe('when the user cannot award emoji', () => {
+ beforeEach(() => {
+ const Component = Vue.extend(awardsNote);
+
+ vm = new Component({
+ store,
+ propsData: {
+ awards: awardsMock,
+ noteAuthorId: 2,
+ noteId: 545,
+ canAwardEmoji: false,
+ toggleAwardPath: '/gitlab-org/gitlab-ce/notes/545/toggle_award_emoji',
+ },
+ }).$mount();
+ });
+
+ it('should not be possible to remove awarded emoji', () => {
+ spyOn(vm, 'toggleAwardRequest').and.callThrough();
+
+ vm.$el.querySelector('.js-awards-block button').click();
+
+ expect(vm.toggleAwardRequest).not.toHaveBeenCalled();
+ });
+
+ it('should not be possible to add new emoji', () => {
+ expect(vm.$el.querySelector('.js-add-award')).toBeNull();
+ });
+ });
});
diff --git a/spec/javascripts/notes/components/note_body_spec.js b/spec/javascripts/notes/components/note_body_spec.js
index 0ff804f0e55..4e551496ff0 100644
--- a/spec/javascripts/notes/components/note_body_spec.js
+++ b/spec/javascripts/notes/components/note_body_spec.js
@@ -18,6 +18,7 @@ describe('issue_note_body component', () => {
propsData: {
note,
canEdit: true,
+ canAwardEmoji: true,
},
}).$mount();
});
diff --git a/spec/javascripts/notes/mock_data.js b/spec/javascripts/notes/mock_data.js
index 24388fba219..bfe3a65feee 100644
--- a/spec/javascripts/notes/mock_data.js
+++ b/spec/javascripts/notes/mock_data.js
@@ -9,6 +9,7 @@ export const notesDataMock = {
totalNotes: 1,
closePath: '/twitter/flight/issues/9.json?issue%5Bstate_event%5D=close',
reopenPath: '/twitter/flight/issues/9.json?issue%5Bstate_event%5D=reopen',
+ canAwardEmoji: true,
};
export const userDataMock = {
@@ -30,6 +31,7 @@ export const noteableDataMock = {
current_user: {
can_create_note: true,
can_update: true,
+ can_award_emoji: true,
},
description: '',
due_date: null,
@@ -86,7 +88,10 @@ export const individualNote = {
human_access: 'Owner',
note: 'sdfdsaf',
note_html: "<p dir='auto'>sdfdsaf</p>",
- current_user: { can_edit: true },
+ current_user: {
+ can_edit: true,
+ can_award_emoji: true,
+ },
discussion_id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd',
emoji_awardable: true,
award_emoji: [
@@ -129,6 +134,7 @@ export const note = {
note_html: '<p dir="auto">Vel id placeat reprehenderit sit numquam.</p>',
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: 'd3842a451b7f3d9a5dfce329515127b2d29a4cd0',
emoji_awardable: true,
@@ -187,6 +193,7 @@ export const discussionMock = {
note_html: "<p dir='auto'>THIS IS A DICUSSSION!</p>",
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true,
@@ -231,6 +238,7 @@ export const discussionMock = {
},
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true,
@@ -275,6 +283,7 @@ export const discussionMock = {
},
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true,
@@ -365,6 +374,7 @@ export const INDIVIDUAL_NOTE_RESPONSE_MAP = {
note_html: '\u003cp dir="auto"\u003esdfdsaf\u003c/p\u003e',
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd',
emoji_awardable: true,
@@ -425,6 +435,7 @@ export const INDIVIDUAL_NOTE_RESPONSE_MAP = {
note_html: '\u003cp dir="auto"\u003eNew note!\u003c/p\u003e',
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: '70d5c92a4039a36c70100c6691c18c27e4b0a790',
emoji_awardable: true,
@@ -478,6 +489,7 @@ export const INDIVIDUAL_NOTE_RESPONSE_MAP = {
},
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: 'a3ed36e29b1957efb3b68c53e2d7a2b24b1df052',
emoji_awardable: true,
@@ -527,6 +539,7 @@ export const DISCUSSION_NOTE_RESPONSE_MAP = {
note_html: '\u003cp dir="auto"\u003eAdding a comment\u003c/p\u003e',
current_user: {
can_edit: true,
+ can_award_emoji: true,
},
discussion_id: 'a3ed36e29b1957efb3b68c53e2d7a2b24b1df052',
emoji_awardable: true,
diff --git a/spec/javascripts/pipelines/pipeline_details_mediator_spec.js b/spec/javascripts/pipelines/pipeline_details_mediator_spec.js
index e58a8018ed5..61ee2dc13ca 100644
--- a/spec/javascripts/pipelines/pipeline_details_mediator_spec.js
+++ b/spec/javascripts/pipelines/pipeline_details_mediator_spec.js
@@ -1,42 +1,36 @@
-import _ from 'underscore';
-import Vue from 'vue';
+import MockAdapter from 'axios-mock-adapter';
+import axios from '~/lib/utils/axios_utils';
import PipelineMediator from '~/pipelines/pipeline_details_mediator';
describe('PipelineMdediator', () => {
let mediator;
+ let mock;
+
beforeEach(() => {
- mediator = new PipelineMediator({ endpoint: 'foo' });
+ mock = new MockAdapter(axios);
+ mediator = new PipelineMediator({ endpoint: 'foo.json' });
+ });
+
+ afterEach(() => {
+ mock.restore();
});
it('should set defaults', () => {
- expect(mediator.options).toEqual({ endpoint: 'foo' });
+ expect(mediator.options).toEqual({ endpoint: 'foo.json' });
expect(mediator.state.isLoading).toEqual(false);
expect(mediator.store).toBeDefined();
expect(mediator.service).toBeDefined();
});
describe('request and store data', () => {
- const interceptor = (request, next) => {
- next(request.respondWith(JSON.stringify({ foo: 'bar' }), {
- status: 200,
- }));
- };
-
- beforeEach(() => {
- Vue.http.interceptors.push(interceptor);
- });
-
- afterEach(() => {
- Vue.http.interceptors = _.without(Vue.http.interceptor, interceptor);
- });
-
- it('should store received data', (done) => {
+ it('should store received data', done => {
+ mock.onGet('foo.json').reply(200, { id: '121123' });
mediator.fetchPipeline();
setTimeout(() => {
- expect(mediator.store.state.pipeline).toEqual({ foo: 'bar' });
+ expect(mediator.store.state.pipeline).toEqual({ id: '121123' });
done();
- });
+ }, 0);
});
});
});
diff --git a/spec/javascripts/pipelines/pipelines_spec.js b/spec/javascripts/pipelines/pipelines_spec.js
index 7e242eb45e1..d79544f83ad 100644
--- a/spec/javascripts/pipelines/pipelines_spec.js
+++ b/spec/javascripts/pipelines/pipelines_spec.js
@@ -1,5 +1,6 @@
-import _ from 'underscore';
import Vue from 'vue';
+import MockAdapter from 'axios-mock-adapter';
+import axios from '~/lib/utils/axios_utils';
import pipelinesComp from '~/pipelines/components/pipelines.vue';
import Store from '~/pipelines/stores/pipelines_store';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
@@ -12,6 +13,8 @@ describe('Pipelines', () => {
let PipelinesComponent;
let pipelines;
let vm;
+ let mock;
+
const paths = {
endpoint: 'twitter/flight/pipelines.json',
autoDevopsPath: '/help/topics/autodevops/index.md',
@@ -34,6 +37,8 @@ describe('Pipelines', () => {
};
beforeEach(() => {
+ mock = new MockAdapter(axios);
+
pipelines = getJSONFixture(jsonFixtureName);
PipelinesComponent = Vue.extend(pipelinesComp);
@@ -41,38 +46,14 @@ describe('Pipelines', () => {
afterEach(() => {
vm.$destroy();
+ mock.restore();
});
- const pipelinesInterceptor = (request, next) => {
- next(request.respondWith(JSON.stringify(pipelines), {
- status: 200,
- }));
- };
-
- const emptyStateInterceptor = (request, next) => {
- next(request.respondWith(JSON.stringify({
- pipelines: [],
- count: {
- all: 0,
- pending: 0,
- running: 0,
- finished: 0,
- },
- }), {
- status: 200,
- }));
- };
-
- const errorInterceptor = (request, next) => {
- next(request.respondWith(JSON.stringify({}), {
- status: 500,
- }));
- };
-
describe('With permission', () => {
describe('With pipelines in main tab', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(pipelinesInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);
+
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: true,
@@ -85,12 +66,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, pipelinesInterceptor,
- );
- });
-
it('renders tabs', () => {
expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All');
});
@@ -116,7 +91,15 @@ describe('Pipelines', () => {
describe('Without pipelines on main tab with CI', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(emptyStateInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(200, {
+ pipelines: [],
+ count: {
+ all: 0,
+ pending: 0,
+ running: 0,
+ finished: 0,
+ },
+ });
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: true,
@@ -129,12 +112,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, emptyStateInterceptor,
- );
- });
-
it('renders tabs', () => {
expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All');
});
@@ -158,7 +135,15 @@ describe('Pipelines', () => {
describe('Without pipelines nor CI', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(emptyStateInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(200, {
+ pipelines: [],
+ count: {
+ all: 0,
+ pending: 0,
+ running: 0,
+ finished: 0,
+ },
+ });
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: false,
@@ -171,12 +156,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, emptyStateInterceptor,
- );
- });
-
it('renders empty state', () => {
expect(vm.$el.querySelector('.js-empty-state h4').textContent.trim()).toEqual('Build with confidence');
expect(vm.$el.querySelector('.js-get-started-pipelines').getAttribute('href')).toEqual(paths.helpPagePath);
@@ -192,7 +171,7 @@ describe('Pipelines', () => {
describe('When API returns error', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(errorInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(500, {});
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: false,
@@ -205,12 +184,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, errorInterceptor,
- );
- });
-
it('renders tabs', () => {
expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All');
});
@@ -230,7 +203,8 @@ describe('Pipelines', () => {
describe('Without permission', () => {
describe('With pipelines in main tab', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(pipelinesInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);
+
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: false,
@@ -243,12 +217,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, pipelinesInterceptor,
- );
- });
-
it('renders tabs', () => {
expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All');
});
@@ -268,7 +236,16 @@ describe('Pipelines', () => {
describe('Without pipelines on main tab with CI', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(emptyStateInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(200, {
+ pipelines: [],
+ count: {
+ all: 0,
+ pending: 0,
+ running: 0,
+ finished: 0,
+ },
+ });
+
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: true,
@@ -281,11 +258,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, emptyStateInterceptor,
- );
- });
it('renders tabs', () => {
expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All');
});
@@ -303,7 +275,16 @@ describe('Pipelines', () => {
describe('Without pipelines nor CI', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(emptyStateInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(200, {
+ pipelines: [],
+ count: {
+ all: 0,
+ pending: 0,
+ running: 0,
+ finished: 0,
+ },
+ });
+
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: false,
@@ -316,12 +297,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, emptyStateInterceptor,
- );
- });
-
it('renders empty state without button to set CI', () => {
expect(vm.$el.querySelector('.js-empty-state').textContent.trim()).toEqual('This project is not currently set up to run pipelines.');
expect(vm.$el.querySelector('.js-get-started-pipelines')).toBeNull();
@@ -337,7 +312,8 @@ describe('Pipelines', () => {
describe('When API returns error', () => {
beforeEach((done) => {
- Vue.http.interceptors.push(errorInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(500, {});
+
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: false,
@@ -350,12 +326,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, errorInterceptor,
- );
- });
-
it('renders tabs', () => {
expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All');
});
@@ -375,7 +345,8 @@ describe('Pipelines', () => {
describe('successfull request', () => {
describe('with pipelines', () => {
beforeEach(() => {
- Vue.http.interceptors.push(pipelinesInterceptor);
+ mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines);
+
vm = mountComponent(PipelinesComponent, {
store: new Store(),
hasGitlabCi: true,
@@ -384,12 +355,6 @@ describe('Pipelines', () => {
});
});
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, pipelinesInterceptor,
- );
- });
-
it('should render table', (done) => {
setTimeout(() => {
expect(vm.$el.querySelector('.table-holder')).toBeDefined();
diff --git a/spec/javascripts/pipelines/stage_spec.js b/spec/javascripts/pipelines/stage_spec.js
index 61c2f783acc..c2ed2e9a31b 100644
--- a/spec/javascripts/pipelines/stage_spec.js
+++ b/spec/javascripts/pipelines/stage_spec.js
@@ -1,27 +1,35 @@
-import _ from 'underscore';
import Vue from 'vue';
+import MockAdapter from 'axios-mock-adapter';
+import axios from '~/lib/utils/axios_utils';
import stage from '~/pipelines/components/stage.vue';
+import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('Pipelines stage component', () => {
let StageComponent;
let component;
+ let mock;
beforeEach(() => {
+ mock = new MockAdapter(axios);
+
StageComponent = Vue.extend(stage);
- component = new StageComponent({
- propsData: {
- stage: {
- status: {
- group: 'success',
- icon: 'icon_status_success',
- title: 'success',
- },
- dropdown_path: 'foo',
+ component = mountComponent(StageComponent, {
+ stage: {
+ status: {
+ group: 'success',
+ icon: 'icon_status_success',
+ title: 'success',
},
- updateDropdown: false,
+ dropdown_path: 'path.json',
},
- }).$mount();
+ updateDropdown: false,
+ });
+ });
+
+ afterEach(() => {
+ component.$destroy();
+ mock.restore();
});
it('should render a dropdown with the status icon', () => {
@@ -31,23 +39,11 @@ describe('Pipelines stage component', () => {
});
describe('with successfull request', () => {
- const interceptor = (request, next) => {
- next(request.respondWith(JSON.stringify({ html: 'foo' }), {
- status: 200,
- }));
- };
-
beforeEach(() => {
- Vue.http.interceptors.push(interceptor);
- });
-
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, interceptor,
- );
+ mock.onGet('path.json').reply(200, { html: 'foo' });
});
- it('should render the received data', (done) => {
+ it('should render the received data', done => {
component.$el.querySelector('button').click();
setTimeout(() => {
@@ -60,20 +56,8 @@ describe('Pipelines stage component', () => {
});
describe('when request fails', () => {
- const interceptor = (request, next) => {
- next(request.respondWith(JSON.stringify({}), {
- status: 500,
- }));
- };
-
beforeEach(() => {
- Vue.http.interceptors.push(interceptor);
- });
-
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, interceptor,
- );
+ mock.onGet('path.json').reply(500);
});
it('should close the dropdown', () => {
@@ -86,33 +70,18 @@ describe('Pipelines stage component', () => {
});
describe('update endpoint correctly', () => {
- const updatedInterceptor = (request, next) => {
- if (request.url === 'bar') {
- next(request.respondWith(JSON.stringify({ html: 'this is the updated content' }), {
- status: 200,
- }));
- }
- next();
- };
-
beforeEach(() => {
- Vue.http.interceptors.push(updatedInterceptor);
- });
-
- afterEach(() => {
- Vue.http.interceptors = _.without(
- Vue.http.interceptors, updatedInterceptor,
- );
+ mock.onGet('bar.json').reply(200, { html: 'this is the updated content' });
});
- it('should update the stage to request the new endpoint provided', (done) => {
+ it('should update the stage to request the new endpoint provided', done => {
component.stage = {
status: {
group: 'running',
icon: 'running',
title: 'running',
},
- dropdown_path: 'bar',
+ dropdown_path: 'bar.json',
};
Vue.nextTick(() => {
@@ -121,7 +90,7 @@ describe('Pipelines stage component', () => {
setTimeout(() => {
expect(
component.$el.querySelector('.js-builds-dropdown-container ul').textContent.trim(),
- ).toEqual('this is the updated content');
+ ).toEqual('this is the updated content');
done();
});
});
diff --git a/spec/javascripts/signin_tabs_memoizer_spec.js b/spec/javascripts/signin_tabs_memoizer_spec.js
index b1b03ef1e09..423432c9e5d 100644
--- a/spec/javascripts/signin_tabs_memoizer_spec.js
+++ b/spec/javascripts/signin_tabs_memoizer_spec.js
@@ -4,7 +4,7 @@ import SigninTabsMemoizer from '~/pages/sessions/new/signin_tabs_memoizer';
(() => {
describe('SigninTabsMemoizer', () => {
const fixtureTemplate = 'static/signin_tabs.html.raw';
- const tabSelector = 'ul.nav-tabs';
+ const tabSelector = 'ul.new-session-tabs';
const currentTabKey = 'current_signin_tab';
let memo;
@@ -27,7 +27,7 @@ import SigninTabsMemoizer from '~/pages/sessions/new/signin_tabs_memoizer';
it('does nothing if no tab was previously selected', () => {
createMemoizer();
- expect(document.querySelector('li a.active').getAttribute('id')).toEqual('standard');
+ expect(document.querySelector(`${tabSelector} > li.active a`).getAttribute('href')).toEqual('#ldap');
});
it('shows last selected tab on boot', () => {
@@ -48,9 +48,9 @@ import SigninTabsMemoizer from '~/pages/sessions/new/signin_tabs_memoizer';
it('saves last selected tab on change', () => {
createMemoizer();
- document.getElementById('standard').click();
+ document.querySelector('a[href="#login-pane"]').click();
- expect(memo.readData()).toEqual('#standard');
+ expect(memo.readData()).toEqual('#login-pane');
});
it('overrides last selected tab with hash tag when given', () => {
diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js
index d158786e484..14bff05e537 100644
--- a/spec/javascripts/test_bundle.js
+++ b/spec/javascripts/test_bundle.js
@@ -5,6 +5,7 @@ import '~/commons';
import Vue from 'vue';
import VueResource from 'vue-resource';
+import Translate from '~/vue_shared/translate';
import { getDefaultAdapter } from '~/lib/utils/axios_utils';
import { FIXTURES_PATH, TEST_HOST } from './test_constants';
@@ -22,12 +23,13 @@ Vue.config.warnHandler = (msg, vm, trace) => {
};
let hasVueErrors = false;
-Vue.config.errorHandler = function (err) {
+Vue.config.errorHandler = function(err) {
hasVueErrors = true;
fail(err);
};
Vue.use(VueResource);
+Vue.use(Translate);
// enable test fixtures
jasmine.getFixtures().fixturesPath = FIXTURES_PATH;
@@ -43,10 +45,11 @@ window.gl = window.gl || {};
window.gl.TEST_HOST = TEST_HOST;
window.gon = window.gon || {};
window.gon.test_env = true;
+gon.relative_url_root = '';
let hasUnhandledPromiseRejections = false;
-window.addEventListener('unhandledrejection', (event) => {
+window.addEventListener('unhandledrejection', event => {
hasUnhandledPromiseRejections = true;
console.error('Unhandled promise rejection:');
console.error(event.reason.stack || event.reason);
@@ -69,15 +72,25 @@ beforeEach(() => {
const axiosDefaultAdapter = getDefaultAdapter();
+let testFiles = process.env.TEST_FILES || [];
+if (testFiles.length > 0) {
+ testFiles = testFiles.map(path => path.replace(/^spec\/javascripts\//, '').replace(/\.js$/, ''));
+ console.log(`Running only tests matching: ${testFiles}`);
+} else {
+ console.log('Running all tests');
+}
+
// render all of our tests
const testsContext = require.context('.', true, /_spec$/);
-testsContext.keys().forEach(function (path) {
+testsContext.keys().forEach(function(path) {
try {
- testsContext(path);
+ if (testFiles.length === 0 || testFiles.some(p => path.includes(p))) {
+ testsContext(path);
+ }
} catch (err) {
console.error('[ERROR] Unable to load spec: ', path);
- describe('Test bundle', function () {
- it(`includes '${path}'`, function () {
+ describe('Test bundle', function() {
+ it(`includes '${path}'`, function() {
expect(err).toBeNull();
});
});
@@ -85,7 +98,7 @@ testsContext.keys().forEach(function (path) {
});
describe('test errors', () => {
- beforeAll((done) => {
+ beforeAll(done => {
if (hasUnhandledPromiseRejections || hasVueWarnings || hasVueErrors) {
setTimeout(done, 1000);
} else {
@@ -149,18 +162,18 @@ if (process.env.BABEL_ENV === 'coverage') {
'./issue_show/index.js',
];
- describe('Uncovered files', function () {
+ describe('Uncovered files', function() {
const sourceFiles = require.context('~', true, /\.js$/);
$.holdReady(true);
- sourceFiles.keys().forEach(function (path) {
+ sourceFiles.keys().forEach(function(path) {
// ignore if there is a matching spec file
if (testsContext.keys().indexOf(`${path.replace(/\.js$/, '')}_spec`) > -1) {
return;
}
- it(`includes '${path}'`, function () {
+ it(`includes '${path}'`, function() {
try {
sourceFiles(path);
} catch (err) {
diff --git a/spec/javascripts/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js b/spec/javascripts/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js
index 046968fbc1f..d797f1266df 100644
--- a/spec/javascripts/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js
+++ b/spec/javascripts/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js
@@ -1,47 +1,37 @@
import Vue from 'vue';
import UnresolvedDiscussions from '~/vue_merge_request_widget/components/states/unresolved_discussions.vue';
+import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('UnresolvedDiscussions', () => {
- describe('props', () => {
- it('should have props', () => {
- const { mr } = UnresolvedDiscussions.props;
+ const Component = Vue.extend(UnresolvedDiscussions);
+ let vm;
- expect(mr.type instanceof Object).toBeTruthy();
- expect(mr.required).toBeTruthy();
- });
+ afterEach(() => {
+ vm.$destroy();
});
- describe('template', () => {
- let el;
- let vm;
- const path = 'foo/bar';
-
+ describe('with discussions path', () => {
beforeEach(() => {
- const Component = Vue.extend(UnresolvedDiscussions);
- const mr = {
- createIssueToResolveDiscussionsPath: path,
- };
- vm = new Component({
- el: document.createElement('div'),
- propsData: { mr },
- });
- el = vm.$el;
+ vm = mountComponent(Component, { mr: {
+ createIssueToResolveDiscussionsPath: gl.TEST_HOST,
+ } });
});
it('should have correct elements', () => {
- expect(el.classList.contains('mr-widget-body')).toBeTruthy();
- expect(el.innerText).toContain('There are unresolved discussions. Please resolve these discussions');
- expect(el.innerText).toContain('Create an issue to resolve them later');
- expect(el.querySelector('.js-create-issue').getAttribute('href')).toEqual(path);
+ expect(vm.$el.innerText).toContain('There are unresolved discussions. Please resolve these discussions');
+ expect(vm.$el.innerText).toContain('Create an issue to resolve them later');
+ expect(vm.$el.querySelector('.js-create-issue').getAttribute('href')).toEqual(gl.TEST_HOST);
});
+ });
- it('should not show create issue button if user cannot create issue', (done) => {
- vm.mr.createIssueToResolveDiscussionsPath = '';
+ describe('without discussions path', () => {
+ beforeEach(() => {
+ vm = mountComponent(Component, { mr: {} });
+ });
- Vue.nextTick(() => {
- expect(el.querySelector('.js-create-issue')).toEqual(null);
- done();
- });
+ it('should not show create issue link if user cannot create issue', () => {
+ expect(vm.$el.innerText).toContain('There are unresolved discussions. Please resolve these discussions');
+ expect(vm.$el.querySelector('.js-create-issue')).toEqual(null);
});
});
});
diff --git a/spec/javascripts/vue_shared/components/markdown/header_spec.js b/spec/javascripts/vue_shared/components/markdown/header_spec.js
index edebd822295..02117638b63 100644
--- a/spec/javascripts/vue_shared/components/markdown/header_spec.js
+++ b/spec/javascripts/vue_shared/components/markdown/header_spec.js
@@ -1,10 +1,11 @@
import Vue from 'vue';
+import $ from 'jquery';
import headerComponent from '~/vue_shared/components/markdown/header.vue';
describe('Markdown field header component', () => {
let vm;
- beforeEach((done) => {
+ beforeEach(done => {
const Component = Vue.extend(headerComponent);
vm = new Component({
@@ -17,24 +18,18 @@ describe('Markdown field header component', () => {
});
it('renders markdown buttons', () => {
- expect(
- vm.$el.querySelectorAll('.js-md').length,
- ).toBe(7);
+ expect(vm.$el.querySelectorAll('.js-md').length).toBe(7);
});
it('renders `write` link as active when previewMarkdown is false', () => {
- expect(
- vm.$el.querySelector('li:nth-child(1)').classList.contains('active'),
- ).toBeTruthy();
+ expect(vm.$el.querySelector('li:nth-child(1)').classList.contains('active')).toBeTruthy();
});
- it('renders `preview` link as active when previewMarkdown is true', (done) => {
+ it('renders `preview` link as active when previewMarkdown is true', done => {
vm.previewMarkdown = true;
Vue.nextTick(() => {
- expect(
- vm.$el.querySelector('li:nth-child(2)').classList.contains('active'),
- ).toBeTruthy();
+ expect(vm.$el.querySelector('li:nth-child(2)').classList.contains('active')).toBeTruthy();
done();
});
@@ -52,16 +47,24 @@ describe('Markdown field header component', () => {
expect(vm.$emit).toHaveBeenCalledWith('write-markdown');
});
- it('blurs preview link after click', (done) => {
+ it('does not emit toggle markdown event when triggered from another form', () => {
+ spyOn(vm, '$emit');
+
+ $(document).triggerHandler('markdown-preview:show', [
+ $('<form><textarea class="markdown-area"></textarea></textarea></form>'),
+ ]);
+
+ expect(vm.$emit).not.toHaveBeenCalled();
+ });
+
+ it('blurs preview link after click', done => {
const link = vm.$el.querySelector('li:nth-child(2) a');
spyOn(HTMLElement.prototype, 'blur');
link.click();
setTimeout(() => {
- expect(
- link.blur,
- ).toHaveBeenCalled();
+ expect(link.blur).toHaveBeenCalled();
done();
});
diff --git a/spec/lib/banzai/commit_renderer_spec.rb b/spec/lib/banzai/commit_renderer_spec.rb
index e7ebb2a332f..1f53657c59c 100644
--- a/spec/lib/banzai/commit_renderer_spec.rb
+++ b/spec/lib/banzai/commit_renderer_spec.rb
@@ -6,7 +6,10 @@ describe Banzai::CommitRenderer do
user = build(:user)
project = create(:project, :repository)
- expect(Banzai::ObjectRenderer).to receive(:new).with(project, user).and_call_original
+ expect(Banzai::ObjectRenderer)
+ .to receive(:new)
+ .with(user: user, default_project: project)
+ .and_call_original
described_class::ATTRIBUTES.each do |attr|
expect_any_instance_of(Banzai::ObjectRenderer).to receive(:render).with([project.commit], attr).once.and_call_original
diff --git a/spec/lib/banzai/issuable_extractor_spec.rb b/spec/lib/banzai/issuable_extractor_spec.rb
index 69763476dac..f42951d9781 100644
--- a/spec/lib/banzai/issuable_extractor_spec.rb
+++ b/spec/lib/banzai/issuable_extractor_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Banzai::IssuableExtractor do
let(:project) { create(:project) }
let(:user) { create(:user) }
- let(:extractor) { described_class.new(project, user) }
+ let(:extractor) { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:issue_link) do
diff --git a/spec/lib/banzai/object_renderer_spec.rb b/spec/lib/banzai/object_renderer_spec.rb
index 074d521a5c6..1fe034ae9a2 100644
--- a/spec/lib/banzai/object_renderer_spec.rb
+++ b/spec/lib/banzai/object_renderer_spec.rb
@@ -3,7 +3,14 @@ require 'spec_helper'
describe Banzai::ObjectRenderer do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
- let(:renderer) { described_class.new(project, user, custom_value: 'value') }
+ let(:renderer) do
+ described_class.new(
+ default_project: project,
+ user: user,
+ redaction_context: { custom_value: 'value' }
+ )
+ end
+
let(:object) { Note.new(note: 'hello', note_html: '<p dir="auto">hello</p>', cached_markdown_version: CacheMarkdownField::CACHE_VERSION) }
describe '#render' do
diff --git a/spec/lib/banzai/redactor_spec.rb b/spec/lib/banzai/redactor_spec.rb
index 441f3725985..aaeec953e4b 100644
--- a/spec/lib/banzai/redactor_spec.rb
+++ b/spec/lib/banzai/redactor_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Banzai::Redactor do
let(:user) { create(:user) }
let(:project) { build(:project) }
- let(:redactor) { described_class.new(project, user) }
+ let(:redactor) { described_class.new(Banzai::RenderContext.new(project, user)) }
describe '#redact' do
context 'when reference not visible to user' do
@@ -54,7 +54,7 @@ describe Banzai::Redactor do
context 'when project is in pending delete' do
let!(:issue) { create(:issue, project: project) }
- let(:redactor) { described_class.new(project, user) }
+ let(:redactor) { described_class.new(Banzai::RenderContext.new(project, user)) }
before do
project.update(pending_delete: true)
diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb
index 6175d4c4ca9..4e6e8eca38a 100644
--- a/spec/lib/banzai/reference_parser/base_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb
@@ -5,13 +5,14 @@ describe Banzai::ReferenceParser::BaseParser do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
+ let(:context) { Banzai::RenderContext.new(project, user) }
subject do
klass = Class.new(described_class) do
self.reference_type = :foo
end
- klass.new(project, user)
+ klass.new(context)
end
describe '.reference_type=' do
@@ -23,6 +24,19 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
+ describe '#project_for_node' do
+ it 'returns the Project for a node' do
+ document = instance_double('document', fragment?: false)
+ project = instance_double('project')
+ object = instance_double('object', project: project)
+ node = instance_double('node', document: document)
+
+ context.associate_document(document, object)
+
+ expect(subject.project_for_node(node)).to eq(project)
+ end
+ end
+
describe '#nodes_visible_to_user' do
let(:link) { empty_html_link }
@@ -164,7 +178,7 @@ describe Banzai::ReferenceParser::BaseParser do
self.reference_type = :test
end
- instance = dummy.new(project, user)
+ instance = dummy.new(Banzai::RenderContext.new(project, user))
document = Nokogiri::HTML.fragment('<a class="gfm"></a><a class="gfm" data-reference-type="test"></a>')
expect(instance).to receive(:gather_references)
diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb
index 3505659c2c3..cca53a8b9b9 100644
--- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb
@@ -5,7 +5,7 @@ describe Banzai::ReferenceParser::CommitParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
diff --git a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb
index 21813177deb..23e16fe0213 100644
--- a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb
@@ -5,7 +5,7 @@ describe Banzai::ReferenceParser::CommitRangeParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
diff --git a/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb b/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
index 25969b65168..1cb31e57114 100644
--- a/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
@@ -5,7 +5,7 @@ describe Banzai::ReferenceParser::ExternalIssueParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb
index cb7f8b20dda..77c2064caba 100644
--- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb
@@ -7,7 +7,7 @@ describe Banzai::ReferenceParser::IssueParser do
let(:user) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:link) { empty_html_link }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
describe '#nodes_visible_to_user' do
context 'when the link has a data-issue attribute' do
diff --git a/spec/lib/banzai/reference_parser/label_parser_spec.rb b/spec/lib/banzai/reference_parser/label_parser_spec.rb
index b700161d6c2..e4df2533821 100644
--- a/spec/lib/banzai/reference_parser/label_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/label_parser_spec.rb
@@ -6,7 +6,7 @@ describe Banzai::ReferenceParser::LabelParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:label) { create(:label, project: project) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
diff --git a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb
index 14542342cf6..5417b1f00be 100644
--- a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb
@@ -6,7 +6,7 @@ describe Banzai::ReferenceParser::MergeRequestParser do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:merge_request) { create(:merge_request, source_project: project) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(merge_request.target_project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
diff --git a/spec/lib/banzai/reference_parser/milestone_parser_spec.rb b/spec/lib/banzai/reference_parser/milestone_parser_spec.rb
index 7dacdf8d629..751d042ffde 100644
--- a/spec/lib/banzai/reference_parser/milestone_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/milestone_parser_spec.rb
@@ -6,7 +6,7 @@ describe Banzai::ReferenceParser::MilestoneParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
diff --git a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
index 69ec3f66aa8..d410bd4c164 100644
--- a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
@@ -9,7 +9,7 @@ describe Banzai::ReferenceParser::SnippetParser do
let(:external_user) { create(:user, :external) }
let(:project_member) { create(:user) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
def visible_references(snippet_visibility, user = nil)
diff --git a/spec/lib/banzai/reference_parser/user_parser_spec.rb b/spec/lib/banzai/reference_parser/user_parser_spec.rb
index b079a3be029..112447f098e 100644
--- a/spec/lib/banzai/reference_parser/user_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/user_parser_spec.rb
@@ -6,7 +6,7 @@ describe Banzai::ReferenceParser::UserParser do
let(:group) { create(:group) }
let(:user) { create(:user) }
let(:project) { create(:project, :public, group: group, creator: user) }
- subject { described_class.new(project, user) }
+ subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#referenced_by' do
diff --git a/spec/lib/banzai/render_context_spec.rb b/spec/lib/banzai/render_context_spec.rb
new file mode 100644
index 00000000000..ad17db11613
--- /dev/null
+++ b/spec/lib/banzai/render_context_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Banzai::RenderContext do
+ let(:document) { Nokogiri::HTML.fragment('<p>hello</p>') }
+
+ describe '#project_for_node' do
+ it 'returns the default project if no associated project was found' do
+ project = instance_double('project')
+ context = described_class.new(project)
+
+ expect(context.project_for_node(document)).to eq(project)
+ end
+
+ it 'returns the associated project if one was associated explicitly' do
+ project = instance_double('project')
+ obj = instance_double('object', project: project)
+ context = described_class.new
+
+ context.associate_document(document, obj)
+
+ expect(context.project_for_node(document)).to eq(project)
+ end
+
+ it 'returns the project associated with a DocumentFragment when using a node' do
+ project = instance_double('project')
+ obj = instance_double('object', project: project)
+ context = described_class.new
+ node = document.children.first
+
+ context.associate_document(document, obj)
+
+ expect(context.project_for_node(node)).to eq(project)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/ci/status/build/common_spec.rb b/spec/lib/gitlab/ci/status/build/common_spec.rb
index 2cce7a23ea7..ca3c66f0152 100644
--- a/spec/lib/gitlab/ci/status/build/common_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/common_spec.rb
@@ -38,4 +38,10 @@ describe Gitlab::Ci::Status::Build::Common do
expect(subject.details_path).to include "jobs/#{build.id}"
end
end
+
+ describe '#illustration' do
+ it 'provides a fallback empty state illustration' do
+ expect(subject.illustration).not_to be_empty
+ end
+ end
end
diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb
index 6d5b73bb01b..d53a7d468e3 100644
--- a/spec/lib/gitlab/ci/status/build/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb
@@ -75,7 +75,8 @@ describe Gitlab::Ci::Status::Build::Factory do
it 'matches correct extended statuses' do
expect(factory.extended_statuses)
- .to eq [Gitlab::Ci::Status::Build::Retryable, Gitlab::Ci::Status::Build::Failed]
+ .to eq [Gitlab::Ci::Status::Build::Retryable,
+ Gitlab::Ci::Status::Build::Failed]
end
it 'fabricates a failed build status' do
@@ -94,7 +95,7 @@ describe Gitlab::Ci::Status::Build::Factory do
end
context 'when build is allowed to fail' do
- let(:build) { create(:ci_build, :failed, :allowed_to_fail) }
+ let(:build) { create(:ci_build, :failed, :allowed_to_fail, :trace_artifact) }
it 'matches correct core status' do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Failed
diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb
index bf9208f1ff4..e79f0a7f257 100644
--- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb
+++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb
@@ -5,6 +5,18 @@ describe Gitlab::Ci::Variables::Collection::Item do
{ key: 'VAR', value: 'something', public: true }
end
+ describe '.new' do
+ it 'raises error if unknown key i specified' do
+ expect { described_class.new(key: 'VAR', value: 'abc', files: true) }
+ .to raise_error ArgumentError, 'unknown keyword: files'
+ end
+
+ it 'raises error when required keywords are not specified' do
+ expect { described_class.new(key: 'VAR') }
+ .to raise_error ArgumentError, 'missing keyword: value'
+ end
+ end
+
describe '.fabricate' do
it 'supports using a hash' do
resource = described_class.fabricate(variable)
@@ -47,12 +59,25 @@ describe Gitlab::Ci::Variables::Collection::Item do
end
describe '#to_runner_variable' do
- it 'returns a runner-compatible hash representation' do
- runner_variable = described_class
- .new(**variable)
- .to_runner_variable
+ context 'when variable is not a file-related' do
+ it 'returns a runner-compatible hash representation' do
+ runner_variable = described_class
+ .new(**variable)
+ .to_runner_variable
+
+ expect(runner_variable).to eq variable
+ end
+ end
+
+ context 'when variable is file-related' do
+ it 'appends file description component' do
+ runner_variable = described_class
+ .new(key: 'VAR', value: 'value', file: true)
+ .to_runner_variable
- expect(runner_variable).to eq variable
+ expect(runner_variable)
+ .to eq(key: 'VAR', value: 'value', public: true, file: true)
+ end
end
end
end
diff --git a/spec/lib/gitlab/email/handler_spec.rb b/spec/lib/gitlab/email/handler_spec.rb
index 386d73e6115..cedbfcc0d18 100644
--- a/spec/lib/gitlab/email/handler_spec.rb
+++ b/spec/lib/gitlab/email/handler_spec.rb
@@ -25,12 +25,12 @@ describe Gitlab::Email::Handler do
described_class.for('email', address).class
end
- expect(matched_handlers.uniq).to match_array(Gitlab::Email::Handler::HANDLERS)
+ expect(matched_handlers.uniq).to match_array(ce_handlers)
end
it 'can pick exactly one handler for each address' do
addresses.each do |address|
- matched_handlers = Gitlab::Email::Handler::HANDLERS.select do |handler|
+ matched_handlers = ce_handlers.select do |handler|
handler.new('email', address).can_handle?
end
@@ -38,4 +38,10 @@ describe Gitlab::Email::Handler do
end
end
end
+
+ def ce_handlers
+ @ce_handlers ||= Gitlab::Email::Handler::HANDLERS.reject do |handler|
+ handler.name.start_with?('Gitlab::Email::Handler::EE::')
+ end
+ end
end
diff --git a/spec/lib/gitlab/git/attributes_parser_spec.rb b/spec/lib/gitlab/git/attributes_parser_spec.rb
index 323334e99a5..2d103123998 100644
--- a/spec/lib/gitlab/git/attributes_parser_spec.rb
+++ b/spec/lib/gitlab/git/attributes_parser_spec.rb
@@ -66,18 +66,6 @@ describe Gitlab::Git::AttributesParser, seed_helper: true do
end
end
- context 'when attributes data is a file handle' do
- subject do
- File.open(attributes_path, 'r') do |file_handle|
- described_class.new(file_handle)
- end
- end
-
- it 'returns the attributes as a Hash' do
- expect(subject.attributes('test.txt')).to eq({ 'text' => true })
- end
- end
-
context 'when attributes data is nil' do
let(:data) { nil }
diff --git a/spec/lib/gitlab/git/info_attributes_spec.rb b/spec/lib/gitlab/git/info_attributes_spec.rb
deleted file mode 100644
index ea84909c3e0..00000000000
--- a/spec/lib/gitlab/git/info_attributes_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::Git::InfoAttributes, seed_helper: true do
- let(:path) do
- File.join(SEED_STORAGE_PATH, 'with-git-attributes.git')
- end
-
- subject { described_class.new(path) }
-
- describe '#attributes' do
- context 'using a path with attributes' do
- it 'returns the attributes as a Hash' do
- expect(subject.attributes('test.txt')).to eq({ 'text' => true })
- end
-
- it 'returns an empty Hash for a defined path without attributes' do
- expect(subject.attributes('bla/bla.txt')).to eq({})
- end
- end
- end
-
- describe '#parser' do
- it 'parses a file with entries' do
- expect(subject.patterns).to be_an_instance_of(Hash)
- expect(subject.patterns["/*.txt"]).to eq({ 'text' => true })
- end
-
- it 'does not parse anything when the attributes file does not exist' do
- expect(File).to receive(:exist?)
- .with(File.join(path, 'info/attributes'))
- .and_return(false)
-
- expect(subject.patterns).to eq({})
- end
-
- it 'does not parse attributes files with unsupported encoding' do
- path = File.join(SEED_STORAGE_PATH, 'with-invalid-git-attributes.git')
- subject = described_class.new(path)
-
- expect(subject.patterns).to eq({})
- end
- end
-end
diff --git a/spec/lib/gitlab/git/raw_diff_change_spec.rb b/spec/lib/gitlab/git/raw_diff_change_spec.rb
new file mode 100644
index 00000000000..eedde34534f
--- /dev/null
+++ b/spec/lib/gitlab/git/raw_diff_change_spec.rb
@@ -0,0 +1,66 @@
+require 'spec_helper'
+
+describe Gitlab::Git::RawDiffChange do
+ let(:raw_change) { }
+ let(:change) { described_class.new(raw_change) }
+
+ context 'bad input' do
+ let(:raw_change) { 'foo' }
+
+ it 'does not set most of the attrs' do
+ expect(change.blob_id).to eq('foo')
+ expect(change.operation).to eq(:unknown)
+ expect(change.old_path).to be_blank
+ expect(change.new_path).to be_blank
+ expect(change.blob_size).to be_blank
+ end
+ end
+
+ context 'adding a file' do
+ let(:raw_change) { '93e123ac8a3e6a0b600953d7598af629dec7b735 59 A bar/branch-test.txt' }
+
+ it 'initialize the proper attrs' do
+ expect(change.operation).to eq(:added)
+ expect(change.old_path).to be_blank
+ expect(change.new_path).to eq('bar/branch-test.txt')
+ expect(change.blob_id).to be_present
+ expect(change.blob_size).to be_present
+ end
+ end
+
+ context 'renaming a file' do
+ let(:raw_change) { "85bc2f9753afd5f4fc5d7c75f74f8d526f26b4f3 107 R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee" }
+
+ it 'initialize the proper attrs' do
+ expect(change.operation).to eq(:renamed)
+ expect(change.old_path).to eq('files/js/commit.js.coffee')
+ expect(change.new_path).to eq('files/js/commit.coffee')
+ expect(change.blob_id).to be_present
+ expect(change.blob_size).to be_present
+ end
+ end
+
+ context 'modifying a file' do
+ let(:raw_change) { 'c60514b6d3d6bf4bec1030f70026e34dfbd69ad5 824 M README.md' }
+
+ it 'initialize the proper attrs' do
+ expect(change.operation).to eq(:modified)
+ expect(change.old_path).to eq('README.md')
+ expect(change.new_path).to eq('README.md')
+ expect(change.blob_id).to be_present
+ expect(change.blob_size).to be_present
+ end
+ end
+
+ context 'deleting a file' do
+ let(:raw_change) { '60d7a906c2fd9e4509aeb1187b98d0ea7ce827c9 15364 D files/.DS_Store' }
+
+ it 'initialize the proper attrs' do
+ expect(change.operation).to eq(:deleted)
+ expect(change.old_path).to eq('files/.DS_Store')
+ expect(change.new_path).to be_nil
+ expect(change.blob_id).to be_present
+ expect(change.blob_size).to be_present
+ end
+ end
+end
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index d3ab61746f4..1e00e8d2739 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -1043,6 +1043,44 @@ describe Gitlab::Git::Repository, seed_helper: true do
it { is_expected.to eq(17) }
end
+ describe '#raw_changes_between' do
+ let(:old_rev) { }
+ let(:new_rev) { }
+ let(:changes) { repository.raw_changes_between(old_rev, new_rev) }
+
+ context 'initial commit' do
+ let(:old_rev) { Gitlab::Git::BLANK_SHA }
+ let(:new_rev) { '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' }
+
+ it 'returns the changes' do
+ expect(changes).to be_present
+ expect(changes.size).to eq(3)
+ end
+ end
+
+ context 'with an invalid rev' do
+ let(:old_rev) { 'foo' }
+ let(:new_rev) { 'bar' }
+
+ it 'returns an error' do
+ expect { changes }.to raise_error(Gitlab::Git::Repository::GitError)
+ end
+ end
+
+ context 'with valid revs' do
+ let(:old_rev) { 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6' }
+ let(:new_rev) { '4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6' }
+
+ it 'returns the changes' do
+ expect(changes.size).to eq(9)
+ expect(changes.first.operation).to eq(:modified)
+ expect(changes.first.new_path).to eq('.gitmodules')
+ expect(changes.last.operation).to eq(:added)
+ expect(changes.last.new_path).to eq('files/lfs/picture-invalid.png')
+ end
+ end
+ end
+
describe '#merge_base' do
shared_examples '#merge_base' do
where(:from, :to, :result) do
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
index 9be3fa633a7..7951cbe7b1d 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -33,7 +33,7 @@ describe Gitlab::GitalyClient::CommitService do
initial_commit = project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863').raw
request = Gitaly::CommitDiffRequest.new(
repository: repository_message,
- left_commit_id: '4b825dc642cb6eb9a060e54bf8d69288fbee4904',
+ left_commit_id: Gitlab::Git::EMPTY_TREE_ID,
right_commit_id: initial_commit.id,
collapse_diffs: true,
enforce_limits: true,
@@ -77,7 +77,7 @@ describe Gitlab::GitalyClient::CommitService do
initial_commit = project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863')
request = Gitaly::CommitDeltaRequest.new(
repository: repository_message,
- left_commit_id: '4b825dc642cb6eb9a060e54bf8d69288fbee4904',
+ left_commit_id: Gitlab::Git::EMPTY_TREE_ID,
right_commit_id: initial_commit.id
)
@@ -90,7 +90,7 @@ describe Gitlab::GitalyClient::CommitService do
describe '#between' do
let(:from) { 'master' }
- let(:to) { '4b825dc642cb6eb9a060e54bf8d69288fbee4904' }
+ let(:to) { Gitlab::Git::EMPTY_TREE_ID }
it 'sends an RPC request' do
request = Gitaly::CommitsBetweenRequest.new(
@@ -155,7 +155,7 @@ describe Gitlab::GitalyClient::CommitService do
end
describe '#find_commit' do
- let(:revision) { '4b825dc642cb6eb9a060e54bf8d69288fbee4904' }
+ let(:revision) { Gitlab::Git::EMPTY_TREE_ID }
it 'sends an RPC request' do
request = Gitaly::FindCommitRequest.new(
repository: repository_message, revision: revision
diff --git a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
index 21592688bf0..074323d47d2 100644
--- a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
@@ -84,6 +84,17 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
+ describe '#info_attributes' do
+ it 'reads the info attributes' do
+ expect_any_instance_of(Gitaly::RepositoryService::Stub)
+ .to receive(:get_info_attributes)
+ .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
+ .and_return([])
+
+ client.info_attributes
+ end
+ end
+
describe '#has_local_branches?' do
it 'sends a has_local_branches message' do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb
index 71a743495a2..4ba99009855 100644
--- a/spec/lib/gitlab/utils_spec.rb
+++ b/spec/lib/gitlab/utils_spec.rb
@@ -1,7 +1,8 @@
require 'spec_helper'
describe Gitlab::Utils do
- delegate :to_boolean, :boolean_to_yes_no, :slugify, :random_string, :which, :ensure_array_from_string, to: :described_class
+ delegate :to_boolean, :boolean_to_yes_no, :slugify, :random_string, :which, :ensure_array_from_string,
+ :bytes_to_megabytes, to: :described_class
describe '.slugify' do
{
@@ -97,4 +98,12 @@ describe Gitlab::Utils do
expect(ensure_array_from_string(str)).to eq(%w[seven eight 9 10])
end
end
+
+ describe '.bytes_to_megabytes' do
+ it 'converts bytes to megabytes' do
+ bytes = 1.megabyte
+
+ expect(bytes_to_megabytes(bytes)).to eq(1)
+ end
+ end
end
diff --git a/spec/lib/rspec_flaky/config_spec.rb b/spec/lib/rspec_flaky/config_spec.rb
index 83556787e85..4a71b1feebd 100644
--- a/spec/lib/rspec_flaky/config_spec.rb
+++ b/spec/lib/rspec_flaky/config_spec.rb
@@ -16,23 +16,25 @@ describe RspecFlaky::Config, :aggregate_failures do
end
end
- context "when ENV['FLAKY_RSPEC_GENERATE_REPORT'] is set to 'false'" do
- before do
- stub_env('FLAKY_RSPEC_GENERATE_REPORT', 'false')
- end
-
- it 'returns false' do
- expect(described_class).not_to be_generate_report
+ context "when ENV['FLAKY_RSPEC_GENERATE_REPORT'] is set" do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:env_value, :result) do
+ '1' | true
+ 'true' | true
+ 'foo' | false
+ '0' | false
+ 'false' | false
end
- end
- context "when ENV['FLAKY_RSPEC_GENERATE_REPORT'] is set to 'true'" do
- before do
- stub_env('FLAKY_RSPEC_GENERATE_REPORT', 'true')
- end
+ with_them do
+ before do
+ stub_env('FLAKY_RSPEC_GENERATE_REPORT', env_value)
+ end
- it 'returns true' do
- expect(described_class).to be_generate_report
+ it 'returns false' do
+ expect(described_class.generate_report?).to be(result)
+ end
end
end
end
diff --git a/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb b/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb
index 06a8ba0d02e..6731a27ed17 100644
--- a/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb
+++ b/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb
@@ -24,14 +24,6 @@ describe RspecFlaky::FlakyExamplesCollection, :aggregate_failures do
}
end
- describe '.from_json' do
- it 'accepts a JSON' do
- collection = described_class.from_json(JSON.pretty_generate(collection_hash))
-
- expect(collection.to_report).to eq(described_class.new(collection_hash).to_report)
- end
- end
-
describe '#initialize' do
it 'accepts no argument' do
expect { described_class.new }.not_to raise_error
@@ -46,11 +38,11 @@ describe RspecFlaky::FlakyExamplesCollection, :aggregate_failures do
end
end
- describe '#to_report' do
+ describe '#to_h' do
it 'calls #to_h on the values' do
collection = described_class.new(collection_hash)
- expect(collection.to_report).to eq(collection_report)
+ expect(collection.to_h).to eq(collection_report)
end
end
@@ -61,7 +53,7 @@ describe RspecFlaky::FlakyExamplesCollection, :aggregate_failures do
a: { example_id: 'spec/foo/bar_spec.rb:2' },
c: { example_id: 'spec/bar/baz_spec.rb:4' })
- expect((collection2 - collection1).to_report).to eq(
+ expect((collection2 - collection1).to_h).to eq(
c: {
example_id: 'spec/bar/baz_spec.rb:4',
first_flaky_at: nil,
diff --git a/spec/lib/rspec_flaky/listener_spec.rb b/spec/lib/rspec_flaky/listener_spec.rb
index bfb7648b486..ef085445081 100644
--- a/spec/lib/rspec_flaky/listener_spec.rb
+++ b/spec/lib/rspec_flaky/listener_spec.rb
@@ -4,7 +4,7 @@ describe RspecFlaky::Listener, :aggregate_failures do
let(:already_flaky_example_uid) { '6e869794f4cfd2badd93eb68719371d1' }
let(:suite_flaky_example_report) do
{
- already_flaky_example_uid => {
+ "#{already_flaky_example_uid}": {
example_id: 'spec/foo/bar_spec.rb:2',
file: 'spec/foo/bar_spec.rb',
line: 2,
@@ -55,8 +55,7 @@ describe RspecFlaky::Listener, :aggregate_failures do
it 'returns a valid Listener instance' do
listener = described_class.new
- expect(listener.to_report(listener.suite_flaky_examples))
- .to eq(expected_suite_flaky_examples)
+ expect(listener.suite_flaky_examples.to_h).to eq(expected_suite_flaky_examples)
expect(listener.flaky_examples).to eq({})
end
end
@@ -65,25 +64,35 @@ describe RspecFlaky::Listener, :aggregate_failures do
it_behaves_like 'a valid Listener instance'
end
- context 'when a report file exists and set by SUITE_FLAKY_RSPEC_REPORT_PATH' do
- let(:report_file) do
- Tempfile.new(%w[rspec_flaky_report .json]).tap do |f|
- f.write(JSON.pretty_generate(suite_flaky_example_report))
- f.rewind
- end
- end
+ context 'when SUITE_FLAKY_RSPEC_REPORT_PATH is set' do
+ let(:report_file_path) { 'foo/report.json' }
before do
- stub_env('SUITE_FLAKY_RSPEC_REPORT_PATH', report_file.path)
+ stub_env('SUITE_FLAKY_RSPEC_REPORT_PATH', report_file_path)
end
- after do
- report_file.close
- report_file.unlink
+ context 'and report file exists' do
+ before do
+ expect(File).to receive(:exist?).with(report_file_path).and_return(true)
+ end
+
+ it 'delegates the load to RspecFlaky::Report' do
+ report = RspecFlaky::Report.new(RspecFlaky::FlakyExamplesCollection.new(suite_flaky_example_report))
+
+ expect(RspecFlaky::Report).to receive(:load).with(report_file_path).and_return(report)
+ expect(described_class.new.suite_flaky_examples.to_h).to eq(report.flaky_examples.to_h)
+ end
end
- it_behaves_like 'a valid Listener instance' do
- let(:expected_suite_flaky_examples) { suite_flaky_example_report }
+ context 'and report file does not exist' do
+ before do
+ expect(File).to receive(:exist?).with(report_file_path).and_return(false)
+ end
+
+ it 'return an empty hash' do
+ expect(RspecFlaky::Report).not_to receive(:load)
+ expect(described_class.new.suite_flaky_examples.to_h).to eq({})
+ end
end
end
end
@@ -186,74 +195,21 @@ describe RspecFlaky::Listener, :aggregate_failures do
let(:notification_already_flaky_rspec_example) { double(example: already_flaky_rspec_example) }
context 'when a report file path is set by FLAKY_RSPEC_REPORT_PATH' do
- let(:report_file_path) { Rails.root.join('tmp', 'rspec_flaky_report.json') }
- let(:new_report_file_path) { Rails.root.join('tmp', 'rspec_flaky_new_report.json') }
+ it 'delegates the writes to RspecFlaky::Report' do
+ listener.example_passed(notification_new_flaky_rspec_example)
+ listener.example_passed(notification_already_flaky_rspec_example)
- before do
- stub_env('FLAKY_RSPEC_REPORT_PATH', report_file_path)
- stub_env('NEW_FLAKY_RSPEC_REPORT_PATH', new_report_file_path)
- FileUtils.rm(report_file_path) if File.exist?(report_file_path)
- FileUtils.rm(new_report_file_path) if File.exist?(new_report_file_path)
- end
+ report1 = double
+ report2 = double
- after do
- FileUtils.rm(report_file_path) if File.exist?(report_file_path)
- FileUtils.rm(new_report_file_path) if File.exist?(new_report_file_path)
- end
+ expect(RspecFlaky::Report).to receive(:new).with(listener.flaky_examples).and_return(report1)
+ expect(report1).to receive(:write).with(RspecFlaky::Config.flaky_examples_report_path)
- context 'when FLAKY_RSPEC_GENERATE_REPORT == "false"' do
- before do
- stub_env('FLAKY_RSPEC_GENERATE_REPORT', 'false')
- end
-
- it 'does not write any report file' do
- listener.example_passed(notification_new_flaky_rspec_example)
+ expect(RspecFlaky::Report).to receive(:new).with(listener.flaky_examples - listener.suite_flaky_examples).and_return(report2)
+ expect(report2).to receive(:write).with(RspecFlaky::Config.new_flaky_examples_report_path)
- listener.dump_summary(nil)
-
- expect(File.exist?(report_file_path)).to be(false)
- expect(File.exist?(new_report_file_path)).to be(false)
- end
+ listener.dump_summary(nil)
end
-
- context 'when FLAKY_RSPEC_GENERATE_REPORT == "true"' do
- before do
- stub_env('FLAKY_RSPEC_GENERATE_REPORT', 'true')
- end
-
- around do |example|
- Timecop.freeze { example.run }
- end
-
- it 'writes the report files' do
- listener.example_passed(notification_new_flaky_rspec_example)
- listener.example_passed(notification_already_flaky_rspec_example)
-
- listener.dump_summary(nil)
-
- expect(File.exist?(report_file_path)).to be(true)
- expect(File.exist?(new_report_file_path)).to be(true)
-
- expect(File.read(report_file_path))
- .to eq(JSON.pretty_generate(listener.to_report(listener.flaky_examples)))
-
- new_example = RspecFlaky::Example.new(notification_new_flaky_rspec_example)
- new_flaky_example = RspecFlaky::FlakyExample.new(new_example)
- new_flaky_example.update_flakiness!
-
- expect(File.read(new_report_file_path))
- .to eq(JSON.pretty_generate(listener.to_report(new_example.uid => new_flaky_example)))
- end
- end
- end
- end
-
- describe '#to_report' do
- let(:listener) { described_class.new(suite_flaky_example_report.to_json) }
-
- it 'transforms the internal hash to a JSON-ready hash' do
- expect(listener.to_report(already_flaky_example_uid => already_flaky_example))
- .to match(hash_including(suite_flaky_example_report))
end
end
end
diff --git a/spec/lib/rspec_flaky/report_spec.rb b/spec/lib/rspec_flaky/report_spec.rb
new file mode 100644
index 00000000000..7d57d99f7e5
--- /dev/null
+++ b/spec/lib/rspec_flaky/report_spec.rb
@@ -0,0 +1,125 @@
+require 'spec_helper'
+
+describe RspecFlaky::Report, :aggregate_failures do
+ let(:a_hundred_days) { 3600 * 24 * 100 }
+ let(:collection_hash) do
+ {
+ a: { example_id: 'spec/foo/bar_spec.rb:2' },
+ b: { example_id: 'spec/foo/baz_spec.rb:3', first_flaky_at: (Time.now - a_hundred_days).to_s, last_flaky_at: (Time.now - a_hundred_days).to_s }
+ }
+ end
+ let(:suite_flaky_example_report) do
+ {
+ '6e869794f4cfd2badd93eb68719371d1': {
+ example_id: 'spec/foo/bar_spec.rb:2',
+ file: 'spec/foo/bar_spec.rb',
+ line: 2,
+ description: 'hello world',
+ first_flaky_at: 1234,
+ last_flaky_at: 4321,
+ last_attempts_count: 3,
+ flaky_reports: 1,
+ last_flaky_job: nil
+ }
+ }
+ end
+ let(:flaky_examples) { RspecFlaky::FlakyExamplesCollection.new(collection_hash) }
+ let(:report) { described_class.new(flaky_examples) }
+
+ describe '.load' do
+ let!(:report_file) do
+ Tempfile.new(%w[rspec_flaky_report .json]).tap do |f|
+ f.write(JSON.pretty_generate(suite_flaky_example_report))
+ f.rewind
+ end
+ end
+
+ after do
+ report_file.close
+ report_file.unlink
+ end
+
+ it 'loads the report file' do
+ expect(described_class.load(report_file.path).flaky_examples.to_h).to eq(suite_flaky_example_report)
+ end
+ end
+
+ describe '.load_json' do
+ let(:report_json) do
+ JSON.pretty_generate(suite_flaky_example_report)
+ end
+
+ it 'loads the report file' do
+ expect(described_class.load_json(report_json).flaky_examples.to_h).to eq(suite_flaky_example_report)
+ end
+ end
+
+ describe '#initialize' do
+ it 'accepts a RspecFlaky::FlakyExamplesCollection' do
+ expect { report }.not_to raise_error
+ end
+
+ it 'does not accept anything else' do
+ expect { described_class.new([1, 2, 3]) }.to raise_error(ArgumentError, "`flaky_examples` must be a RspecFlaky::FlakyExamplesCollection, Array given!")
+ end
+ end
+
+ it 'delegates to #flaky_examples using SimpleDelegator' do
+ expect(report.__getobj__).to eq(flaky_examples)
+ end
+
+ describe '#write' do
+ let(:report_file_path) { Rails.root.join('tmp', 'rspec_flaky_report.json') }
+
+ before do
+ FileUtils.rm(report_file_path) if File.exist?(report_file_path)
+ end
+
+ after do
+ FileUtils.rm(report_file_path) if File.exist?(report_file_path)
+ end
+
+ context 'when RspecFlaky::Config.generate_report? is false' do
+ before do
+ allow(RspecFlaky::Config).to receive(:generate_report?).and_return(false)
+ end
+
+ it 'does not write any report file' do
+ report.write(report_file_path)
+
+ expect(File.exist?(report_file_path)).to be(false)
+ end
+ end
+
+ context 'when RspecFlaky::Config.generate_report? is true' do
+ before do
+ allow(RspecFlaky::Config).to receive(:generate_report?).and_return(true)
+ end
+
+ it 'delegates the writes to RspecFlaky::Report' do
+ report.write(report_file_path)
+
+ expect(File.exist?(report_file_path)).to be(true)
+ expect(File.read(report_file_path))
+ .to eq(JSON.pretty_generate(report.flaky_examples.to_h))
+ end
+ end
+ end
+
+ describe '#prune_outdated' do
+ it 'returns a new collection without the examples older than 90 days by default' do
+ new_report = flaky_examples.to_h.dup.tap { |r| r.delete(:b) }
+ new_flaky_examples = report.prune_outdated
+
+ expect(new_flaky_examples).to be_a(described_class)
+ expect(new_flaky_examples.to_h).to eq(new_report)
+ expect(flaky_examples).to have_key(:b)
+ end
+
+ it 'accepts a given number of days' do
+ new_flaky_examples = report.prune_outdated(days: 200)
+
+ expect(new_flaky_examples.to_h).to eq(report.to_h)
+ end
+ end
+end
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb
index cd175dba6da..199f49d0bf2 100644
--- a/spec/models/ability_spec.rb
+++ b/spec/models/ability_spec.rb
@@ -7,62 +7,6 @@ describe Ability do
end
end
- describe '.can_edit_note?' do
- let(:project) { create(:project) }
- let(:note) { create(:note_on_issue, project: project) }
-
- context 'using an anonymous user' do
- it 'returns false' do
- expect(described_class.can_edit_note?(nil, note)).to be_falsy
- end
- end
-
- context 'using a system note' do
- it 'returns false' do
- system_note = create(:note, system: true)
- user = create(:user)
-
- expect(described_class.can_edit_note?(user, system_note)).to be_falsy
- end
- end
-
- context 'using users with different access levels' do
- let(:user) { create(:user) }
-
- it 'returns true for the author' do
- expect(described_class.can_edit_note?(note.author, note)).to be_truthy
- end
-
- it 'returns false for a guest user' do
- project.add_guest(user)
-
- expect(described_class.can_edit_note?(user, note)).to be_falsy
- end
-
- it 'returns false for a developer' do
- project.add_developer(user)
-
- expect(described_class.can_edit_note?(user, note)).to be_falsy
- end
-
- it 'returns true for a master' do
- project.add_master(user)
-
- expect(described_class.can_edit_note?(user, note)).to be_truthy
- end
-
- it 'returns true for a group owner' do
- group = create(:group)
- project.project_group_links.create(
- group: group,
- group_access: Gitlab::Access::MASTER)
- group.add_owner(user)
-
- expect(described_class.can_edit_note?(user, note)).to be_truthy
- end
- end
- end
-
describe '.users_that_can_read_project' do
context 'using a public project' do
it 'returns all the users' do
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 461e754dc1f..5326f9cb8c0 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -51,7 +51,11 @@ describe BroadcastMessage do
expect(described_class).to receive(:where).and_call_original.once
- 2.times { described_class.current }
+ described_class.current
+
+ Timecop.travel(1.year) do
+ described_class.current
+ end
end
it 'includes messages that need to be displayed in the future' do
diff --git a/spec/models/concerns/awardable_spec.rb b/spec/models/concerns/awardable_spec.rb
index 34f923d3f0c..a980cff28fb 100644
--- a/spec/models/concerns/awardable_spec.rb
+++ b/spec/models/concerns/awardable_spec.rb
@@ -46,6 +46,31 @@ describe Awardable do
end
end
+ describe '#user_can_award?' do
+ let(:user) { create(:user) }
+
+ before do
+ issue.project.add_guest(user)
+ end
+
+ it 'does not allow upvoting or downvoting your own issue' do
+ issue.update!(author: user)
+
+ expect(issue.user_can_award?(user, AwardEmoji::DOWNVOTE_NAME)).to be_falsy
+ expect(issue.user_can_award?(user, AwardEmoji::UPVOTE_NAME)).to be_falsy
+ end
+
+ it 'is truthy when the user is allowed to award emoji' do
+ expect(issue.user_can_award?(user, AwardEmoji::UPVOTE_NAME)).to be_truthy
+ end
+
+ it 'is falsy when the project is archived' do
+ issue.project.update!(archived: true)
+
+ expect(issue.user_can_award?(user, AwardEmoji::UPVOTE_NAME)).to be_falsy
+ end
+ end
+
describe "#toggle_award_emoji" do
it "adds an emoji if it isn't awarded yet" do
expect { issue.toggle_award_emoji("thumbsup", award_emoji.user) }.to change { AwardEmoji.count }.by(1)
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb
index 5a15c23def4..780b200e837 100644
--- a/spec/models/deploy_token_spec.rb
+++ b/spec/models/deploy_token_spec.rb
@@ -78,19 +78,30 @@ describe DeployToken do
describe '#has_access_to?' do
let(:project) { create(:project) }
- subject(:deploy_token) { create(:deploy_token, projects: [project]) }
+ subject { deploy_token.has_access_to?(project) }
- context 'when the deploy token has access to the project' do
- it 'should return true' do
- expect(deploy_token.has_access_to?(project)).to be_truthy
- end
+ context 'when deploy token is active and related to project' do
+ let(:deploy_token) { create(:deploy_token, projects: [project]) }
+
+ it { is_expected.to be_truthy }
end
- context 'when the deploy token does not have access to the project' do
- it 'should return false' do
- another_project = create(:project)
- expect(deploy_token.has_access_to?(another_project)).to be_falsy
- end
+ context 'when deploy token is active but not related to project' do
+ let(:deploy_token) { create(:deploy_token) }
+
+ it { is_expected.to be_falsy }
+ end
+
+ context 'when deploy token is revoked and related to project' do
+ let(:deploy_token) { create(:deploy_token, :revoked, projects: [project]) }
+
+ it { is_expected.to be_falsy }
+ end
+
+ context 'when deploy token is revoked and not related to the project' do
+ let(:deploy_token) { create(:deploy_token, :revoked) }
+
+ it { is_expected.to be_falsy }
end
end
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index d87c1ca14f0..374a157bec0 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -172,11 +172,12 @@ describe ProjectWiki do
describe '#find_file' do
shared_examples 'finding a wiki file' do
+ let(:image) { File.open(Rails.root.join('spec', 'fixtures', 'big-image.png')) }
+
before do
- file = File.open(Rails.root.join('spec', 'fixtures', 'dk.png'))
subject.wiki # Make sure the wiki repo exists
- BareRepoOperations.new(subject.repository.path_to_repo).commit_file(file, 'image.png')
+ BareRepoOperations.new(subject.repository.path_to_repo).commit_file(image, 'image.png')
end
it 'returns the latest version of the file if it exists' do
@@ -192,6 +193,13 @@ describe ProjectWiki do
file = subject.find_file('image.png')
expect(file).to be_a Gitlab::Git::WikiFile
end
+
+ it 'returns the whole file' do
+ file = subject.find_file('image.png')
+ image.rewind
+
+ expect(file.raw_data.b).to eq(image.read.b)
+ end
end
context 'when Gitaly wiki_find_file is enabled' do
diff --git a/spec/policies/note_policy_spec.rb b/spec/policies/note_policy_spec.rb
index 58d36a2c84e..e8096358f7d 100644
--- a/spec/policies/note_policy_spec.rb
+++ b/spec/policies/note_policy_spec.rb
@@ -18,7 +18,6 @@ describe NotePolicy, mdoels: true do
context 'when the project is public' do
context 'when the note author is not a project member' do
it 'can edit a note' do
- expect(policies).to be_allowed(:update_note)
expect(policies).to be_allowed(:admin_note)
expect(policies).to be_allowed(:resolve_note)
expect(policies).to be_allowed(:read_note)
@@ -29,7 +28,6 @@ describe NotePolicy, mdoels: true do
it 'can edit note' do
policies = policies(create(:project_snippet, project: project))
- expect(policies).to be_allowed(:update_note)
expect(policies).to be_allowed(:admin_note)
expect(policies).to be_allowed(:resolve_note)
expect(policies).to be_allowed(:read_note)
@@ -47,7 +45,6 @@ describe NotePolicy, mdoels: true do
end
it 'can edit a note' do
- expect(policies).to be_allowed(:update_note)
expect(policies).to be_allowed(:admin_note)
expect(policies).to be_allowed(:resolve_note)
expect(policies).to be_allowed(:read_note)
@@ -56,7 +53,6 @@ describe NotePolicy, mdoels: true do
context 'when the note author is not a project member' do
it 'can not edit a note' do
- expect(policies).to be_disallowed(:update_note)
expect(policies).to be_disallowed(:admin_note)
expect(policies).to be_disallowed(:resolve_note)
end
diff --git a/spec/policies/personal_snippet_policy_spec.rb b/spec/policies/personal_snippet_policy_spec.rb
index 50bb0899eba..3809692b373 100644
--- a/spec/policies/personal_snippet_policy_spec.rb
+++ b/spec/policies/personal_snippet_policy_spec.rb
@@ -27,6 +27,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_allowed(:read_personal_snippet)
is_expected.to be_disallowed(:comment_personal_snippet)
+ is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -37,6 +38,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_allowed(:read_personal_snippet)
is_expected.to be_allowed(:comment_personal_snippet)
+ is_expected.to be_allowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -47,6 +49,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_allowed(:read_personal_snippet)
is_expected.to be_allowed(:comment_personal_snippet)
+ is_expected.to be_allowed(:award_emoji)
is_expected.to be_allowed(*author_permissions)
end
end
@@ -61,6 +64,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_disallowed(:read_personal_snippet)
is_expected.to be_disallowed(:comment_personal_snippet)
+ is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -71,6 +75,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_allowed(:read_personal_snippet)
is_expected.to be_allowed(:comment_personal_snippet)
+ is_expected.to be_allowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -81,6 +86,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_disallowed(:read_personal_snippet)
is_expected.to be_disallowed(:comment_personal_snippet)
+ is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -91,6 +97,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_allowed(:read_personal_snippet)
is_expected.to be_allowed(:comment_personal_snippet)
+ is_expected.to be_allowed(:award_emoji)
is_expected.to be_allowed(*author_permissions)
end
end
@@ -105,6 +112,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_disallowed(:read_personal_snippet)
is_expected.to be_disallowed(:comment_personal_snippet)
+ is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -115,6 +123,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_disallowed(:read_personal_snippet)
is_expected.to be_disallowed(:comment_personal_snippet)
+ is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -125,6 +134,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_disallowed(:read_personal_snippet)
is_expected.to be_disallowed(:comment_personal_snippet)
+ is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
end
end
@@ -135,6 +145,7 @@ describe PersonalSnippetPolicy do
it do
is_expected.to be_allowed(:read_personal_snippet)
is_expected.to be_allowed(:comment_personal_snippet)
+ is_expected.to be_allowed(:award_emoji)
is_expected.to be_allowed(*author_permissions)
end
end
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index 905d82b3bb1..8b9c4ac0b4b 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -14,7 +14,8 @@ describe ProjectPolicy do
read_project read_board read_list read_wiki read_issue
read_project_for_iids read_issue_iid read_merge_request_iid read_label
read_milestone read_project_snippet read_project_member read_note
- create_project create_issue create_note upload_file
+ create_project create_issue create_note upload_file create_merge_request_in
+ award_emoji
]
end
@@ -35,7 +36,7 @@ describe ProjectPolicy do
%i[
admin_milestone admin_merge_request update_merge_request create_commit_status
update_commit_status create_build update_build create_pipeline
- update_pipeline create_merge_request create_wiki push_code
+ update_pipeline create_merge_request_from create_wiki push_code
resolve_note create_container_image update_container_image
create_environment create_deployment
]
@@ -43,7 +44,7 @@ describe ProjectPolicy do
let(:base_master_permissions) do
%i[
- delete_protected_branch update_project_snippet update_environment
+ push_to_delete_protected_branch update_project_snippet update_environment
update_deployment admin_project_snippet
admin_project_member admin_note admin_wiki admin_project
admin_commit_status admin_build admin_container_image
@@ -136,13 +137,66 @@ describe ProjectPolicy do
end
end
+ context 'merge requests feature' do
+ subject { described_class.new(owner, project) }
+
+ it 'disallows all permissions when the feature is disabled' do
+ project.project_feature.update(merge_requests_access_level: ProjectFeature::DISABLED)
+
+ mr_permissions = [:create_merge_request_from, :read_merge_request,
+ :update_merge_request, :admin_merge_request,
+ :create_merge_request_in]
+
+ expect_disallowed(*mr_permissions)
+ end
+ end
+
+ shared_examples 'archived project policies' do
+ let(:feature_write_abilities) do
+ described_class::READONLY_FEATURES_WHEN_ARCHIVED.flat_map do |feature|
+ described_class.create_update_admin_destroy(feature)
+ end
+ end
+
+ let(:other_write_abilities) do
+ %i[
+ create_merge_request_in
+ create_merge_request_from
+ push_to_delete_protected_branch
+ push_code
+ request_access
+ upload_file
+ resolve_note
+ award_emoji
+ ]
+ end
+
+ context 'when the project is archived' do
+ before do
+ project.archived = true
+ end
+
+ it 'disables write actions on all relevant project features' do
+ expect_disallowed(*feature_write_abilities)
+ end
+
+ it 'disables some other important write actions' do
+ expect_disallowed(*other_write_abilities)
+ end
+
+ it 'does not disable other other abilities' do
+ expect_allowed(*(regular_abilities - feature_write_abilities - other_write_abilities))
+ end
+ end
+ end
+
shared_examples 'project policies as anonymous' do
context 'abilities for public projects' do
context 'when a project has pending invites' do
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, namespace: group) }
- let(:user_permissions) { [:create_project, :create_issue, :create_note, :upload_file] }
- let(:anonymous_permissions) { guest_permissions - user_permissions }
+ let(:user_permissions) { [:create_merge_request_in, :create_project, :create_issue, :create_note, :upload_file, :award_emoji] }
+ let(:anonymous_permissions) { guest_permissions - user_permissions }
subject { described_class.new(nil, project) }
@@ -154,6 +208,10 @@ describe ProjectPolicy do
expect_allowed(*anonymous_permissions)
expect_disallowed(*user_permissions)
end
+
+ it_behaves_like 'archived project policies' do
+ let(:regular_abilities) { anonymous_permissions }
+ end
end
end
@@ -184,6 +242,10 @@ describe ProjectPolicy do
expect_disallowed(*owner_permissions)
end
+ it_behaves_like 'archived project policies' do
+ let(:regular_abilities) { guest_permissions }
+ end
+
context 'public builds enabled' do
it do
expect_allowed(*guest_permissions)
@@ -224,12 +286,15 @@ describe ProjectPolicy do
it do
expect_allowed(*guest_permissions)
expect_allowed(*reporter_permissions)
- expect_allowed(*reporter_permissions)
expect_allowed(*team_member_reporter_permissions)
expect_disallowed(*developer_permissions)
expect_disallowed(*master_permissions)
expect_disallowed(*owner_permissions)
end
+
+ it_behaves_like 'archived project policies' do
+ let(:regular_abilities) { reporter_permissions }
+ end
end
end
@@ -247,6 +312,10 @@ describe ProjectPolicy do
expect_disallowed(*master_permissions)
expect_disallowed(*owner_permissions)
end
+
+ it_behaves_like 'archived project policies' do
+ let(:regular_abilities) { developer_permissions }
+ end
end
end
@@ -264,6 +333,10 @@ describe ProjectPolicy do
expect_allowed(*master_permissions)
expect_disallowed(*owner_permissions)
end
+
+ it_behaves_like 'archived project policies' do
+ let(:regular_abilities) { master_permissions }
+ end
end
end
@@ -281,6 +354,10 @@ describe ProjectPolicy do
expect_allowed(*master_permissions)
expect_allowed(*owner_permissions)
end
+
+ it_behaves_like 'archived project policies' do
+ let(:regular_abilities) { owner_permissions }
+ end
end
end
@@ -298,6 +375,10 @@ describe ProjectPolicy do
expect_allowed(*master_permissions)
expect_allowed(*owner_permissions)
end
+
+ it_behaves_like 'archived project policies' do
+ let(:regular_abilities) { owner_permissions }
+ end
end
end
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 3764aec0c71..f64623d7018 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -861,7 +861,7 @@ describe API::MergeRequests do
expect(json_response['title']).to eq('Test merge_request')
end
- it 'returns 422 when target project has disabled merge requests' do
+ it 'returns 403 when target project has disabled merge requests' do
project.project_feature.update(merge_requests_access_level: 0)
post api("/projects/#{forked_project.id}/merge_requests", user2),
@@ -871,7 +871,7 @@ describe API::MergeRequests do
author: user2,
target_project_id: project.id
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(403)
end
it "returns 400 when source_branch is missing" do
diff --git a/spec/requests/api/v3/merge_requests_spec.rb b/spec/requests/api/v3/merge_requests_spec.rb
index 6b748369f0d..be70cb24dce 100644
--- a/spec/requests/api/v3/merge_requests_spec.rb
+++ b/spec/requests/api/v3/merge_requests_spec.rb
@@ -340,7 +340,7 @@ describe API::MergeRequests do
expect(json_response['title']).to eq('Test merge_request')
end
- it "returns 422 when target project has disabled merge requests" do
+ it "returns 403 when target project has disabled merge requests" do
project.project_feature.update(merge_requests_access_level: 0)
post v3_api("/projects/#{forked_project.id}/merge_requests", user2),
@@ -350,7 +350,7 @@ describe API::MergeRequests do
author: user2,
target_project_id: project.id
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(403)
end
it "returns 400 when source_branch is missing" do
diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb
index 290eeae828e..da8e660c16b 100644
--- a/spec/services/auth/container_registry_authentication_service_spec.rb
+++ b/spec/services/auth/container_registry_authentication_service_spec.rb
@@ -585,4 +585,140 @@ describe Auth::ContainerRegistryAuthenticationService do
it_behaves_like 'not a container repository factory'
end
end
+
+ context 'for deploy tokens' do
+ let(:current_params) do
+ { scope: "repository:#{project.full_path}:pull" }
+ end
+
+ context 'when deploy token has read_registry as a scope' do
+ let(:current_user) { create(:deploy_token, projects: [project]) }
+
+ context 'for public project' do
+ let(:project) { create(:project, :public) }
+
+ context 'when pulling' do
+ it_behaves_like 'a pullable'
+ end
+
+ context 'when pushing' do
+ let(:current_params) do
+ { scope: "repository:#{project.full_path}:push" }
+ end
+
+ it_behaves_like 'an inaccessible'
+ end
+ end
+
+ context 'for internal project' do
+ let(:project) { create(:project, :internal) }
+
+ context 'when pulling' do
+ it_behaves_like 'a pullable'
+ end
+
+ context 'when pushing' do
+ let(:current_params) do
+ { scope: "repository:#{project.full_path}:push" }
+ end
+
+ it_behaves_like 'an inaccessible'
+ end
+ end
+
+ context 'for private project' do
+ let(:project) { create(:project, :private) }
+
+ context 'when pulling' do
+ it_behaves_like 'a pullable'
+ end
+
+ context 'when pushing' do
+ let(:current_params) do
+ { scope: "repository:#{project.full_path}:push" }
+ end
+
+ it_behaves_like 'an inaccessible'
+ end
+ end
+ end
+
+ context 'when deploy token does not have read_registry scope' do
+ let(:current_user) { create(:deploy_token, projects: [project], read_registry: false) }
+
+ context 'for public project' do
+ let(:project) { create(:project, :public) }
+
+ context 'when pulling' do
+ it_behaves_like 'a pullable'
+ end
+ end
+
+ context 'for internal project' do
+ let(:project) { create(:project, :internal) }
+
+ context 'when pulling' do
+ it_behaves_like 'an inaccessible'
+ end
+ end
+
+ context 'for private project' do
+ let(:project) { create(:project, :internal) }
+
+ context 'when pulling' do
+ it_behaves_like 'an inaccessible'
+ end
+ end
+ end
+
+ context 'when deploy token is not related to the project' do
+ let(:current_user) { create(:deploy_token, read_registry: false) }
+
+ context 'for public project' do
+ let(:project) { create(:project, :public) }
+
+ context 'when pulling' do
+ it_behaves_like 'a pullable'
+ end
+ end
+
+ context 'for internal project' do
+ let(:project) { create(:project, :internal) }
+
+ context 'when pulling' do
+ it_behaves_like 'an inaccessible'
+ end
+ end
+
+ context 'for private project' do
+ let(:project) { create(:project, :internal) }
+
+ context 'when pulling' do
+ it_behaves_like 'an inaccessible'
+ end
+ end
+ end
+
+ context 'when deploy token has been revoked' do
+ let(:current_user) { create(:deploy_token, :revoked, projects: [project]) }
+
+ context 'for public project' do
+ let(:project) { create(:project, :public) }
+
+ it_behaves_like 'a pullable'
+ end
+
+ context 'for internal project' do
+ let(:project) { create(:project, :internal) }
+
+ it_behaves_like 'an inaccessible'
+ end
+
+ context 'for private project' do
+ let(:project) { create(:project, :internal) }
+
+ it_behaves_like 'an inaccessible'
+ end
+ end
+ end
end
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb
index aa7cc268dd7..97a563c1ce1 100644
--- a/spec/services/ci/register_job_service_spec.rb
+++ b/spec/services/ci/register_job_service_spec.rb
@@ -370,89 +370,10 @@ module Ci
it_behaves_like 'validation is not active'
end
end
- end
- describe '#register_success' do
- let!(:current_time) { Time.new(2018, 4, 5, 14, 0, 0) }
- let!(:attempt_counter) { double('Gitlab::Metrics::NullMetric') }
- let!(:job_queue_duration_seconds) { double('Gitlab::Metrics::NullMetric') }
-
- before do
- allow(Time).to receive(:now).and_return(current_time)
-
- # Stub defaults for any metrics other than the ones we're testing
- allow(Gitlab::Metrics).to receive(:counter)
- .with(any_args)
- .and_return(Gitlab::Metrics::NullMetric.instance)
- allow(Gitlab::Metrics).to receive(:histogram)
- .with(any_args)
- .and_return(Gitlab::Metrics::NullMetric.instance)
-
- # Stub tested metrics
- allow(Gitlab::Metrics).to receive(:counter)
- .with(:job_register_attempts_total, anything)
- .and_return(attempt_counter)
- allow(Gitlab::Metrics).to receive(:histogram)
- .with(:job_queue_duration_seconds, anything, anything, anything)
- .and_return(job_queue_duration_seconds)
-
- project.update(shared_runners_enabled: true)
- pending_job.update(created_at: current_time - 3600, queued_at: current_time - 1800)
+ def execute(runner)
+ described_class.new(runner).execute.build
end
-
- shared_examples 'metrics collector' do
- it 'increments attempt counter' do
- allow(job_queue_duration_seconds).to receive(:observe)
- expect(attempt_counter).to receive(:increment)
-
- execute(runner)
- end
-
- it 'counts job queuing time histogram with expected labels' do
- allow(attempt_counter).to receive(:increment)
- expect(job_queue_duration_seconds).to receive(:observe)
- .with({ shared_runner: expected_shared_runner,
- jobs_running_for_project: expected_jobs_running_for_project_first_job }, 1800)
-
- execute(runner)
- end
-
- context 'when project already has running jobs' do
- let!(:build2) { create( :ci_build, :running, pipeline: pipeline, runner: shared_runner) }
- let!(:build3) { create( :ci_build, :running, pipeline: pipeline, runner: shared_runner) }
-
- it 'counts job queuing time histogram with expected labels' do
- allow(attempt_counter).to receive(:increment)
- expect(job_queue_duration_seconds).to receive(:observe)
- .with({ shared_runner: expected_shared_runner,
- jobs_running_for_project: expected_jobs_running_for_project_third_job }, 1800)
-
- execute(runner)
- end
- end
- end
-
- context 'when shared runner is used' do
- let(:runner) { shared_runner }
- let(:expected_shared_runner) { true }
- let(:expected_jobs_running_for_project_first_job) { 0 }
- let(:expected_jobs_running_for_project_third_job) { 2 }
-
- it_behaves_like 'metrics collector'
- end
-
- context 'when specific runner is used' do
- let(:runner) { specific_runner }
- let(:expected_shared_runner) { false }
- let(:expected_jobs_running_for_project_first_job) { '+Inf' }
- let(:expected_jobs_running_for_project_third_job) { '+Inf' }
-
- it_behaves_like 'metrics collector'
- end
- end
-
- def execute(runner)
- described_class.new(runner).execute.build
end
end
end
diff --git a/spec/services/events/render_service_spec.rb b/spec/services/events/render_service_spec.rb
index b4a4a44d07b..075cb45e46c 100644
--- a/spec/services/events/render_service_spec.rb
+++ b/spec/services/events/render_service_spec.rb
@@ -9,9 +9,7 @@ describe Events::RenderService do
context 'when the request format is atom' do
it 'renders the note inside events' do
expect(Banzai::ObjectRenderer).to receive(:new)
- .with(event.project, user,
- only_path: false,
- xhtml: true)
+ .with(user: user, redaction_context: { only_path: false, xhtml: true })
.and_call_original
expect_any_instance_of(Banzai::ObjectRenderer)
@@ -24,7 +22,7 @@ describe Events::RenderService do
context 'when the request format is not atom' do
it 'renders the note inside events' do
expect(Banzai::ObjectRenderer).to receive(:new)
- .with(event.project, user, {})
+ .with(user: user, redaction_context: {})
.and_call_original
expect_any_instance_of(Banzai::ObjectRenderer)
diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb
index 44a83c436cb..736a50b2c15 100644
--- a/spec/services/merge_requests/create_service_spec.rb
+++ b/spec/services/merge_requests/create_service_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
describe MergeRequests::CreateService do
+ include ProjectForksHelper
+
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:assignee) { create(:user) }
@@ -300,7 +302,7 @@ describe MergeRequests::CreateService do
end
context 'when source and target projects are different' do
- let(:target_project) { create(:project) }
+ let(:target_project) { fork_project(project, nil, repository: true) }
let(:opts) do
{
@@ -334,6 +336,26 @@ describe MergeRequests::CreateService do
.to raise_error Gitlab::Access::AccessDeniedError
end
end
+
+ context 'when the user has access to both projects' do
+ before do
+ target_project.add_developer(user)
+ project.add_developer(user)
+ end
+
+ it 'creates the merge request' do
+ merge_request = described_class.new(project, user, opts).execute
+
+ expect(merge_request).to be_persisted
+ end
+
+ it 'does not create the merge request when the target project is archived' do
+ target_project.update!(archived: true)
+
+ expect { described_class.new(project, user, opts).execute }
+ .to raise_error Gitlab::Access::AccessDeniedError
+ end
+ end
end
context 'when user sets source project id' do
diff --git a/spec/services/notes/render_service_spec.rb b/spec/services/notes/render_service_spec.rb
index faac498037f..f771620bc0d 100644
--- a/spec/services/notes/render_service_spec.rb
+++ b/spec/services/notes/render_service_spec.rb
@@ -4,23 +4,28 @@ describe Notes::RenderService do
describe '#execute' do
it 'renders a Note' do
note = double(:note)
- project = double(:project)
wiki = double(:wiki)
user = double(:user)
- expect(Banzai::ObjectRenderer).to receive(:new)
- .with(project, user,
- requested_path: 'foo',
- project_wiki: wiki,
- ref: 'bar',
- only_path: nil,
- xhtml: false)
+ expect(Banzai::ObjectRenderer)
+ .to receive(:new)
+ .with(
+ user: user,
+ redaction_context: {
+ requested_path: 'foo',
+ project_wiki: wiki,
+ ref: 'bar',
+ only_path: nil,
+ xhtml: false
+ }
+ )
.and_call_original
expect_any_instance_of(Banzai::ObjectRenderer)
- .to receive(:render).with([note], :note)
+ .to receive(:render)
+ .with([note], :note)
- described_class.new(user).execute([note], project,
+ described_class.new(user).execute([note],
requested_path: 'foo',
project_wiki: wiki,
ref: 'bar',
diff --git a/spec/support/bare_repo_operations.rb b/spec/support/bare_repo_operations.rb
index 8eeaa37d3c5..3f4a4243cb6 100644
--- a/spec/support/bare_repo_operations.rb
+++ b/spec/support/bare_repo_operations.rb
@@ -1,19 +1,15 @@
require 'zlib'
class BareRepoOperations
- # The ID of empty tree.
- # See http://stackoverflow.com/a/40884093/1856239 and https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012
- EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze
-
include Gitlab::Popen
def initialize(path_to_repo)
@path_to_repo = path_to_repo
end
- def commit_tree(tree_id, msg, parent: EMPTY_TREE_ID)
+ def commit_tree(tree_id, msg, parent: Gitlab::Git::EMPTY_TREE_ID)
commit_tree_args = ['commit-tree', tree_id, '-m', msg]
- commit_tree_args += ['-p', parent] unless parent == EMPTY_TREE_ID
+ commit_tree_args += ['-p', parent] unless parent == Gitlab::Git::EMPTY_TREE_ID
commit_id = execute(commit_tree_args)
commit_id[0]
@@ -21,7 +17,7 @@ class BareRepoOperations
# Based on https://stackoverflow.com/a/25556917/1856239
def commit_file(file, dst_path, branch = 'master')
- head_id = execute(['show', '--format=format:%H', '--no-patch', branch], allow_failure: true)[0] || EMPTY_TREE_ID
+ head_id = execute(['show', '--format=format:%H', '--no-patch', branch], allow_failure: true)[0] || Gitlab::Git::EMPTY_TREE_ID
execute(['read-tree', '--empty'])
execute(['read-tree', head_id])
diff --git a/spec/support/filter_spec_helper.rb b/spec/support/filter_spec_helper.rb
index b871b7ffc90..721d359c2ee 100644
--- a/spec/support/filter_spec_helper.rb
+++ b/spec/support/filter_spec_helper.rb
@@ -18,6 +18,11 @@ module FilterSpecHelper
context.reverse_merge!(project: project)
end
+ render_context = Banzai::RenderContext
+ .new(context[:project], context[:current_user])
+
+ context = context.merge(render_context: render_context)
+
described_class.call(html, context)
end
diff --git a/spec/support/helpers/features/branches_helpers.rb b/spec/support/helpers/features/branches_helpers.rb
new file mode 100644
index 00000000000..3525d9a70a7
--- /dev/null
+++ b/spec/support/helpers/features/branches_helpers.rb
@@ -0,0 +1,33 @@
+# These helpers allow you to manipulate with sorting features.
+#
+# Usage:
+# describe "..." do
+# include Spec::Support::Helpers::Features::BranchesHelpers
+# ...
+#
+# create_branch("feature")
+# select_branch("master")
+#
+module Spec
+ module Support
+ module Helpers
+ module Features
+ module BranchesHelpers
+ def create_branch(branch_name, source_branch_name = "master")
+ fill_in("branch_name", with: branch_name)
+ select_branch(source_branch_name)
+ click_button("Create branch")
+ end
+
+ def select_branch(branch_name)
+ find(".git-revision-dropdown-toggle").click
+
+ page.within("#new-branch-form .dropdown-menu") do
+ click_link(branch_name)
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/matchers/have_emoji.rb b/spec/support/matchers/have_emoji.rb
new file mode 100644
index 00000000000..23fb8e9c1c4
--- /dev/null
+++ b/spec/support/matchers/have_emoji.rb
@@ -0,0 +1,5 @@
+RSpec::Matchers.define :have_emoji do |emoji_name|
+ match do |actual|
+ expect(actual).to have_selector("gl-emoji[data-name='#{emoji_name}']")
+ end
+end
diff --git a/spec/support/reference_parser_helpers.rb b/spec/support/reference_parser_helpers.rb
index 5d5e80851e6..c01897ed1a1 100644
--- a/spec/support/reference_parser_helpers.rb
+++ b/spec/support/reference_parser_helpers.rb
@@ -5,9 +5,11 @@ module ReferenceParserHelpers
shared_examples 'no N+1 queries' do
it 'avoids N+1 queries in #nodes_visible_to_user', :request_store do
+ context = Banzai::RenderContext.new(project, user)
+
record_queries = lambda do |links|
ActiveRecord::QueryRecorder.new do
- described_class.new(project, user).nodes_visible_to_user(user, links)
+ described_class.new(context).nodes_visible_to_user(user, links)
end
end
@@ -19,9 +21,11 @@ module ReferenceParserHelpers
end
it 'avoids N+1 queries in #records_for_nodes', :request_store do
+ context = Banzai::RenderContext.new(project, user)
+
record_queries = lambda do |links|
ActiveRecord::QueryRecorder.new do
- described_class.new(project, user).records_for_nodes(links)
+ described_class.new(context).records_for_nodes(links)
end
end
diff --git a/spec/views/projects/buttons/_dropdown.html.haml_spec.rb b/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
index d0e692635b9..8b9aab30286 100644
--- a/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
+++ b/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
@@ -8,7 +8,8 @@ describe 'projects/buttons/_dropdown' do
assign(:project, project)
allow(view).to receive(:current_user).and_return(user)
- allow(view).to receive(:can?).and_return(true)
+ allow(view).to receive(:can?).with(user, :push_code, project).and_return(true)
+ allow(view).to receive(:can_collaborate_with_project?).and_return(true)
end
context 'empty repository' do
diff --git a/spec/views/projects/commit/_commit_box.html.haml_spec.rb b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
index 448b925cf34..2fdd28a3be4 100644
--- a/spec/views/projects/commit/_commit_box.html.haml_spec.rb
+++ b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
@@ -7,6 +7,7 @@ describe 'projects/commit/_commit_box.html.haml' do
before do
assign(:project, project)
assign(:commit, project.commit)
+ allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:can_collaborate_with_project?).and_return(false)
end
@@ -47,7 +48,8 @@ describe 'projects/commit/_commit_box.html.haml' do
context 'viewing a commit' do
context 'as a developer' do
before do
- expect(view).to receive(:can_collaborate_with_project?).and_return(true)
+ project.add_developer(user)
+ allow(view).to receive(:can_collaborate_with_project?).and_return(true)
end
it 'has a link to create a new tag' do
@@ -58,10 +60,6 @@ describe 'projects/commit/_commit_box.html.haml' do
end
context 'as a non-developer' do
- before do
- expect(view).to receive(:can_collaborate_with_project?).and_return(false)
- end
-
it 'does not have a link to create a new tag' do
render
diff --git a/vendor/gitignore/Android.gitignore b/vendor/gitignore/Android.gitignore
index d57137223ed..39b6783cef8 100644
--- a/vendor/gitignore/Android.gitignore
+++ b/vendor/gitignore/Android.gitignore
@@ -37,8 +37,10 @@ captures/
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
+.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
+.idea/caches
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
diff --git a/vendor/gitignore/Elixir.gitignore b/vendor/gitignore/Elixir.gitignore
index b6d65867dac..86e4c3f3905 100644
--- a/vendor/gitignore/Elixir.gitignore
+++ b/vendor/gitignore/Elixir.gitignore
@@ -6,3 +6,4 @@
erl_crash.dump
*.ez
*.beam
+/config/*.secret.exs
diff --git a/vendor/gitignore/Global/JetBrains.gitignore b/vendor/gitignore/Global/JetBrains.gitignore
index 9c01e12b050..a83a428c844 100644
--- a/vendor/gitignore/Global/JetBrains.gitignore
+++ b/vendor/gitignore/Global/JetBrains.gitignore
@@ -1,12 +1,12 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-# User-specific stuff:
+# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
-# Sensitive or high-churn files:
+# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
@@ -14,7 +14,7 @@
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
-# Gradle:
+# Gradle
.idea/**/gradle.xml
.idea/**/libraries
@@ -22,14 +22,12 @@
cmake-build-debug/
cmake-build-release/
-# Mongo Explorer plugin:
+# Mongo Explorer plugin
.idea/**/mongoSettings.xml
-## File-based project format:
+# File-based project format
*.iws
-## Plugin-specific files:
-
# IntelliJ
out/
@@ -47,3 +45,6 @@ com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
diff --git a/vendor/gitignore/Global/Windows.gitignore b/vendor/gitignore/Global/Windows.gitignore
index 846a1db836c..0251dd21ad8 100644
--- a/vendor/gitignore/Global/Windows.gitignore
+++ b/vendor/gitignore/Global/Windows.gitignore
@@ -15,6 +15,7 @@ $RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
+*.msix
*.msm
*.msp
diff --git a/vendor/gitignore/Godot.gitignore b/vendor/gitignore/Godot.gitignore
new file mode 100644
index 00000000000..ba45ca4582e
--- /dev/null
+++ b/vendor/gitignore/Godot.gitignore
@@ -0,0 +1,8 @@
+
+# Godot-specific ignores
+.import/
+export.cfg
+export_presets.cfg
+
+# Mono-specific ignores
+.mono/
diff --git a/vendor/gitignore/Joomla.gitignore b/vendor/gitignore/Joomla.gitignore
index b6bf3a9c96a..378c158bddf 100644
--- a/vendor/gitignore/Joomla.gitignore
+++ b/vendor/gitignore/Joomla.gitignore
@@ -1,4 +1,3 @@
-/.gitignore
/.htaccess
/administrator/cache/*
/administrator/components/com_admin/*
diff --git a/vendor/gitignore/KiCad.gitignore b/vendor/gitignore/KiCad.gitignore
index 208bc4fc591..198392e551e 100644
--- a/vendor/gitignore/KiCad.gitignore
+++ b/vendor/gitignore/KiCad.gitignore
@@ -1,4 +1,5 @@
# For PCBs designed using KiCad: http://www.kicad-pcb.org/
+# Format documentation: http://kicad-pcb.org/help/file-formats/
# Temporary files
*.000
@@ -8,6 +9,10 @@
*~
_autosave-*
*.tmp
+*-cache.lib
+*-rescue.lib
+*-save.pro
+*-save.kicad_pcb
# Netlist files (exported from Eeschema)
*.net
diff --git a/vendor/gitignore/Leiningen.gitignore b/vendor/gitignore/Leiningen.gitignore
index a9fe6fba80d..a4cb69a32cc 100644
--- a/vendor/gitignore/Leiningen.gitignore
+++ b/vendor/gitignore/Leiningen.gitignore
@@ -11,3 +11,4 @@ pom.xml.asc
.lein-plugins/
.lein-failures
.nrepl-port
+.cpcache/
diff --git a/vendor/gitignore/Node.gitignore b/vendor/gitignore/Node.gitignore
index d1bed128fa8..ad46b30886f 100644
--- a/vendor/gitignore/Node.gitignore
+++ b/vendor/gitignore/Node.gitignore
@@ -36,7 +36,7 @@ build/Release
node_modules/
jspm_packages/
-# Typescript v1 declaration files
+# TypeScript v1 declaration files
typings/
# Optional npm cache directory
diff --git a/vendor/gitignore/Python.gitignore b/vendor/gitignore/Python.gitignore
index b989be6ca15..894a44cc066 100644
--- a/vendor/gitignore/Python.gitignore
+++ b/vendor/gitignore/Python.gitignore
@@ -53,9 +53,8 @@ coverage.xml
# Django stuff:
*.log
-.static_storage/
-.media/
local_settings.py
+db.sqlite3
# Flask stuff:
instance/
diff --git a/vendor/gitignore/Rails.gitignore b/vendor/gitignore/Rails.gitignore
index 828ab1d556a..e62f78e17bc 100644
--- a/vendor/gitignore/Rails.gitignore
+++ b/vendor/gitignore/Rails.gitignore
@@ -14,6 +14,7 @@ pickle-email-*.html
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
config/initializers/secret_token.rb
+config/master.key
# Only include if you have production secrets in this file, which is no longer a Rails default
# config/secrets.yml
diff --git a/vendor/gitignore/Rust.gitignore b/vendor/gitignore/Rust.gitignore
index 50281a44270..088ba6ba7d3 100644
--- a/vendor/gitignore/Rust.gitignore
+++ b/vendor/gitignore/Rust.gitignore
@@ -3,7 +3,7 @@
/target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
-# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
+# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
diff --git a/vendor/gitignore/TeX.gitignore b/vendor/gitignore/TeX.gitignore
index 78c1c5cd26e..c560658e45c 100644
--- a/vendor/gitignore/TeX.gitignore
+++ b/vendor/gitignore/TeX.gitignore
@@ -153,7 +153,9 @@ _minted*
*.mw
# nomencl
+*.nlg
*.nlo
+*.nls
# pax
*.pax
diff --git a/vendor/gitignore/Unity.gitignore b/vendor/gitignore/Unity.gitignore
index 75e5b1405da..a7c0c70a0b4 100644
--- a/vendor/gitignore/Unity.gitignore
+++ b/vendor/gitignore/Unity.gitignore
@@ -5,7 +5,7 @@
[Bb]uilds/
Assets/AssetStoreTools*
-# Visual Studio 2015 cache directory
+# Visual Studio cache directory
/.vs/
# Autogenerated VS/MD/Consulo solution and project files
diff --git a/vendor/gitignore/VisualStudio.gitignore b/vendor/gitignore/VisualStudio.gitignore
index 8e930f59c47..29063cf6072 100644
--- a/vendor/gitignore/VisualStudio.gitignore
+++ b/vendor/gitignore/VisualStudio.gitignore
@@ -64,8 +64,10 @@ StyleCopReport.xml
*.ilk
*.meta
*.obj
+*.iobj
*.pch
*.pdb
+*.ipdb
*.pgc
*.pgd
*.rsp
@@ -248,6 +250,7 @@ ServiceFabricBackup/
*.rdl.data
*.bim.layout
*.bim_*.settings
+*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
@@ -319,3 +322,8 @@ ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
diff --git a/vendor/gitlab-ci-yml/Auto-DevOps.gitlab-ci.yml b/vendor/gitlab-ci-yml/Auto-DevOps.gitlab-ci.yml
index 4223dc18933..4810035a9e3 100644
--- a/vendor/gitlab-ci-yml/Auto-DevOps.gitlab-ci.yml
+++ b/vendor/gitlab-ci-yml/Auto-DevOps.gitlab-ci.yml
@@ -50,9 +50,9 @@ stages:
build:
stage: build
- image: docker:git
+ image: docker:stable-git
services:
- - docker:dind
+ - docker:stable-dind
variables:
DOCKER_DRIVER: overlay2
script:
@@ -76,12 +76,12 @@ test:
- branches
codequality:
- image: docker:latest
+ image: docker:stable
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- - docker:dind
+ - docker:stable-dind
script:
- setup_docker
- codeclimate
@@ -90,12 +90,12 @@ codequality:
performance:
stage: performance
- image: docker:latest
+ image: docker:stable
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- - docker:dind
+ - docker:stable-dind
script:
- setup_docker
- performance
@@ -109,25 +109,37 @@ performance:
kubernetes: active
sast:
- image: docker:latest
+ image: docker:stable
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- - docker:dind
+ - docker:stable-dind
script:
- setup_docker
- sast
artifacts:
paths: [gl-sast-report.json]
+dependency_scanning:
+ image: docker:stable
+ variables:
+ DOCKER_DRIVER: overlay2
+ allow_failure: true
+ services:
+ - docker:stable-dind
+ script:
+ - setup_docker
+ - dependency_scanning
+ artifacts:
+ paths: [gl-dependency-scanning-report.json]
sast:container:
- image: docker:latest
+ image: docker:stable
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- - docker:dind
+ - docker:stable-dind
script:
- setup_docker
- sast_container
@@ -324,7 +336,6 @@ production:
fi
docker run --env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}" \
- --env SAST_DISABLE_REMOTE_CHECKS="${SAST_DISABLE_REMOTE_CHECKS:-false}" \
--volume "$PWD:/code" \
--volume /var/run/docker.sock:/var/run/docker.sock \
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
@@ -335,6 +346,20 @@ production:
esac
}
+ function dependency_scanning() {
+ case "$CI_SERVER_VERSION" in
+ *-ee)
+ docker run --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}" \
+ --volume "$PWD:/code" \
+ --volume /var/run/docker.sock:/var/run/docker.sock \
+ "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
+ ;;
+ *)
+ echo "GitLab EE is required"
+ ;;
+ esac
+ }
+
function deploy() {
track="${1-stable}"
name="$CI_ENVIRONMENT_SLUG"
@@ -355,10 +380,16 @@ production:
if [[ "$track" == "stable" ]]; then
# for stable track get number of replicas from `PRODUCTION_REPLICAS`
eval new_replicas=\$${env_slug}_REPLICAS
+ if [[ -z "$new_replicas" ]]; then
+ new_replicas=$REPLICAS
+ fi
service_enabled="true"
else
# for all tracks get number of replicas from `CANARY_PRODUCTION_REPLICAS`
eval new_replicas=\$${env_track}_${env_slug}_REPLICAS
+ if [[ -z "$new_replicas" ]]; then
+ eval new_replicas=\${env_track}_REPLICAS
+ fi
fi
if [[ -n "$new_replicas" ]]; then
replicas="$new_replicas"
diff --git a/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml b/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml
index 0ad662cf704..0688f77a1d2 100644
--- a/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml
+++ b/vendor/gitlab-ci-yml/Laravel.gitlab-ci.yml
@@ -32,7 +32,7 @@ before_script:
- apt-get install git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
# Install php extensions
- - docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache
+ - docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache
# Install & enable Xdebug for code coverage reports
- pecl install xdebug
diff --git a/vendor/gitlab-ci-yml/Pages/Gatsby.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/Gatsby.gitlab-ci.yml
new file mode 100644
index 00000000000..9df2a4797b2
--- /dev/null
+++ b/vendor/gitlab-ci-yml/Pages/Gatsby.gitlab-ci.yml
@@ -0,0 +1,17 @@
+image: node:latest
+
+# This folder is cached between builds
+# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
+cache:
+ paths:
+ - node_modules/
+
+pages:
+ script:
+ - yarn install
+ - ./node_modules/.bin/gatsby build --prefix-paths
+ artifacts:
+ paths:
+ - public
+ only:
+ - master
diff --git a/vendor/gitlab-ci-yml/Pages/Hugo.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/Hugo.gitlab-ci.yml
index a72b8281401..b8cfb0f56f6 100644
--- a/vendor/gitlab-ci-yml/Pages/Hugo.gitlab-ci.yml
+++ b/vendor/gitlab-ci-yml/Pages/Hugo.gitlab-ci.yml
@@ -1,5 +1,5 @@
# Full project: https://gitlab.com/pages/hugo
-image: publysher/hugo
+image: dettmering/hugo-build
pages:
script:
diff --git a/vendor/gitlab-ci-yml/Python.gitlab-ci.yml b/vendor/gitlab-ci-yml/Python.gitlab-ci.yml
index a2882a5407d..2e0589de652 100644
--- a/vendor/gitlab-ci-yml/Python.gitlab-ci.yml
+++ b/vendor/gitlab-ci-yml/Python.gitlab-ci.yml
@@ -1,8 +1,27 @@
-# This file is a template, and might need editing before it works on your project.
+# Official language image. Look for the different tagged releases at:
+# https://hub.docker.com/r/library/python/tags/
image: python:latest
+# Change pip's cache directory to be inside the project directory since we can
+# only cache local items.
+variables:
+ PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache"
+
+# Pip's cache doesn't store the python packages
+# https://pip.pypa.io/en/stable/reference/pip_install/#caching
+#
+# If you want to also cache the installed packages, you have to install
+# them in a virtualenv and cache it as well.
+cache:
+ paths:
+ - .cache/pip
+ - venv/
+
before_script:
- - python -V # Print out python version for debugging
+ - python -V # Print out python version for debugging
+ - pip install virtualenv
+ - virtualenv venv
+ - source venv/bin/activate
test:
script:
diff --git a/vendor/licenses.csv b/vendor/licenses.csv
index 03115292f02..ca88f867fe5 100644
--- a/vendor/licenses.csv
+++ b/vendor/licenses.csv
@@ -4,7 +4,7 @@
@babel/template,7.0.0-beta.32,MIT
@babel/traverse,7.0.0-beta.32,MIT
@babel/types,7.0.0-beta.32,MIT
-@gitlab-org/gitlab-svgs,1.8.0,SEE LICENSE IN LICENSE
+@gitlab-org/gitlab-svgs,1.17.0,SEE LICENSE IN LICENSE
@types/jquery,2.0.48,MIT
JSONStream,1.3.2,MIT
RedCloth,4.3.2,MIT
@@ -27,10 +27,11 @@ activejob,4.2.10,MIT
activemodel,4.2.10,MIT
activerecord,4.2.10,MIT
activesupport,4.2.10,MIT
-acts-as-taggable-on,4.0.0,MIT
+acts-as-taggable-on,5.0.0,MIT
address,1.0.3,MIT
addressable,2.5.2,Apache 2.0
addressparser,1.0.1,MIT
+aes_key_wrap,1.0.1,MIT
after,0.8.2,MIT
agent-base,2.1.1,MIT
ajv,4.11.8,MIT
@@ -80,8 +81,8 @@ array-unique,0.3.2,MIT
arraybuffer.slice,0.0.7,MIT
arrify,1.0.1,MIT
asana,0.6.0,MIT
-asciidoctor,1.5.3,MIT
-asciidoctor-plantuml,0.0.7,MIT
+asciidoctor,1.5.6.2,MIT
+asciidoctor-plantuml,0.0.8,MIT
asn1,0.2.3,MIT
asn1.js,4.10.1,MIT
assert,1.4.1,MIT
@@ -205,8 +206,8 @@ better-assert,1.0.2,MIT
bfj-node4,5.2.1,MIT
big.js,3.1.3,MIT
binary-extensions,1.11.0,MIT
-bindata,2.4.1,ruby
-bitsyntax,0.0.4,Unknown
+bindata,2.4.3,ruby
+bitsyntax,0.0.4,UNKNOWN
bl,1.1.2,MIT
blackst0ne-mermaid,7.1.0-fixed,MIT
blob,0.0.4,MIT*
@@ -274,7 +275,7 @@ chalk,1.1.3,MIT
chalk,2.3.0,MIT
chalk,2.3.1,MIT
chardet,0.4.2,MIT
-charlock_holmes,0.7.5,MIT
+charlock_holmes,0.7.6,MIT
chart.js,1.0.2,MIT
check-types,7.3.0,MIT
chokidar,1.7.0,MIT
@@ -314,7 +315,7 @@ combine-lists,1.0.1,MIT
combine-source-map,0.7.2,MIT
combine-source-map,0.8.0,MIT
combined-stream,1.0.6,MIT
-commander,2.14.1,MIT
+commander,2.15.1,MIT
commondir,1.0.1,MIT
commonmarker,0.17.8,MIT
component-bind,1.0.0,MIT*
@@ -352,6 +353,7 @@ core-js,2.5.3,MIT
core-util-is,1.0.2,MIT
cosmiconfig,2.1.1,MIT
crack,0.4.3,MIT
+crass,1.0.3,MIT
create-ecdh,4.0.0,MIT
create-error-class,3.0.2,MIT
create-hash,1.1.3,MIT
@@ -457,13 +459,13 @@ document-register-element,1.3.0,MIT
dom-serialize,2.2.1,MIT
dom-serializer,0.1.0,MIT
domain-browser,1.1.7,MIT
-domain_name,0.5.20161021,"Simplified BSD,New BSD,Mozilla Public License 2.0"
+domain_name,0.5.20170404,"Simplified BSD,New BSD,Mozilla Public License 2.0"
domelementtype,1.1.3,Simplified BSD
domelementtype,1.3.0,Simplified BSD
domhandler,2.4.1,Simplified BSD
domutils,1.6.2,Simplified BSD
-doorkeeper,4.2.6,MIT
-doorkeeper-openid_connect,1.2.0,MIT
+doorkeeper,4.3.1,MIT
+doorkeeper-openid_connect,1.3.0,MIT
dot-prop,4.2.0,MIT
double-ended-queue,2.1.0-0,MIT
dropzone,4.2.0,MIT
@@ -543,7 +545,7 @@ eventemitter3,1.2.0,MIT
events,1.1.1,MIT
eventsource,0.1.6,MIT
evp_bytestokey,1.0.3,MIT
-excon,0.57.1,MIT
+excon,0.60.0,MIT
execa,0.7.0,MIT
execjs,2.6.0,MIT
exit-hook,1.1.1,MIT
@@ -571,7 +573,7 @@ fast-deep-equal,1.0.0,MIT
fast-json-stable-stringify,2.0.0,MIT
fast-levenshtein,2.0.6,MIT
fast_blank,1.0.0,MIT
-fast_gettext,1.4.0,"MIT,ruby"
+fast_gettext,1.6.0,"MIT,ruby"
fastparse,1.1.1,MIT
faye-websocket,0.10.0,MIT
faye-websocket,0.11.1,MIT
@@ -594,15 +596,15 @@ find-up,1.1.2,MIT
find-up,2.1.0,MIT
flat-cache,1.2.2,MIT
flatten,1.0.2,MIT
-flipper,0.11.0,MIT
-flipper-active_record,0.11.0,MIT
-flipper-active_support_cache_store,0.11.0,MIT
+flipper,0.13.0,MIT
+flipper-active_record,0.13.0,MIT
+flipper-active_support_cache_store,0.13.0,MIT
flowdock,0.7.1,MIT
flush-write-stream,1.0.2,MIT
fog-aliyun,0.2.0,MIT
-fog-aws,1.4.0,MIT
-fog-core,1.44.3,MIT
-fog-google,0.5.3,MIT
+fog-aws,2.0.1,MIT
+fog-core,1.45.0,MIT
+fog-google,1.3.3,MIT
fog-json,1.0.2,MIT
fog-local,0.3.1,MIT
fog-openstack,0.1.21,MIT
@@ -646,8 +648,8 @@ get-value,2.0.6,MIT
get_process_mem,0.2.0,MIT
getpass,0.1.7,MIT
gettext_i18n_rails,1.8.0,MIT
-gettext_i18n_rails_js,1.2.0,MIT
-gitaly-proto,0.88.0,MIT
+gettext_i18n_rails_js,1.3.0,MIT
+gitaly-proto,0.94.0,MIT
github-linguist,5.3.3,MIT
github-markup,1.6.1,MIT
gitlab-flowdock-git-hook,1.0.1,MIT
@@ -669,12 +671,13 @@ globals,9.18.0,MIT
globby,5.0.0,MIT
globby,6.1.0,MIT
globby,7.1.1,MIT
+goldiloader,2.0.1,MIT
gollum-grit_adapter,1.0.1,MIT
gollum-lib,4.2.7,MIT
gollum-rugged_adapter,0.4.4,MIT
gon,6.1.0,MIT
good-listener,1.2.2,MIT
-google-api-client,0.13.6,Apache 2.0
+google-api-client,0.19.8,Apache 2.0
google-protobuf,3.5.1,New BSD
googleapis-common-protos-types,1.0.1,Apache 2.0
googleauth,0.6.2,Apache 2.0
@@ -682,7 +685,7 @@ got,6.7.1,MIT
got,7.1.0,MIT
gpgme,2.0.13,LGPL-2.1+
graceful-fs,4.1.11,ISC
-grape,1.0.0,MIT
+grape,1.0.2,MIT
grape-entity,0.6.0,MIT
grape-route-helpers,2.1.0,MIT
grape_logging,1.7.0,MIT
@@ -716,7 +719,7 @@ hash-base,2.0.2,MIT
hash-base,3.0.4,MIT
hash-sum,1.0.2,MIT
hash.js,1.1.3,MIT
-hashie,3.5.6,MIT
+hashie,3.5.7,MIT
hashie-forbidden_attributes,0.1.1,MIT
hawk,3.1.3,New BSD
hawk,6.0.2,New BSD
@@ -733,16 +736,16 @@ hosted-git-info,2.2.0,ISC
hpack.js,2.1.6,MIT
html-comment-regex,1.1.1,MIT
html-entities,1.2.0,MIT
-html-pipeline,1.11.0,MIT
+html-pipeline,2.7.1,MIT
html2text,0.2.0,MIT
htmlentities,4.3.4,MIT
htmlescape,1.1.1,MIT
htmlparser2,3.9.2,MIT
-http,0.9.8,MIT
+http,2.2.2,MIT
http-cookie,1.0.3,MIT
http-deceiver,1.2.7,MIT
http-errors,1.6.2,MIT
-http-form_data,1.0.1,MIT
+http-form_data,1.0.3,MIT
http-proxy,1.16.2,MIT
http-proxy-agent,1.0.0,MIT
http-proxy-middleware,0.17.4,MIT
@@ -750,13 +753,13 @@ http-signature,1.1.1,MIT
http-signature,1.2.0,MIT
http_parser.rb,0.6.0,MIT
httparty,0.13.7,MIT
-httpclient,2.8.2,ruby
+httpclient,2.8.3,ruby
httpntlm,1.6.1,MIT
httpreq,0.4.24,MIT
https-browserify,0.0.1,MIT
https-browserify,1.0.0,MIT
https-proxy-agent,1.0.0,MIT
-i18n,0.9.1,MIT
+i18n,0.9.5,MIT
ice_nine,0.11.2,MIT
iconv-lite,0.4.15,MIT
iconv-lite,0.4.19,MIT
@@ -881,7 +884,6 @@ jed,1.1.1,MIT
jira-ruby,1.4.1,MIT
jquery,3.3.1,MIT
jquery-atwho-rails,1.3.2,MIT
-jquery-rails,4.3.1,MIT
jquery-ujs,1.2.2,MIT
jquery.waitforimages,2.2.0,MIT
js-base64,2.1.9,New BSD
@@ -893,7 +895,7 @@ jsbn,0.1.1,MIT
jsesc,0.5.0,MIT
jsesc,1.3.0,MIT
json,1.8.6,ruby
-json-jwt,1.7.2,MIT
+json-jwt,1.9.2,MIT
json-loader,0.5.7,MIT
json-schema,0.2.3,BSD
json-schema-traverse,0.3.1,MIT
@@ -927,7 +929,7 @@ kind-of,3.2.2,MIT
kind-of,4.0.0,MIT
kind-of,5.1.0,MIT
kind-of,6.0.2,MIT
-kubeclient,2.2.0,MIT
+kubeclient,3.0.0,MIT
labeled-stream-splicer,2.0.0,MIT
latest-version,3.1.0,MIT
lazy-cache,1.0.4,MIT
@@ -938,7 +940,7 @@ lexical-scope,1.2.0,MIT
libbase64,0.1.0,MIT
libmime,3.0.0,MIT
libqp,1.1.0,MIT
-licensee,8.7.0,MIT
+licensee,8.9.2,MIT
lie,3.1.1,MIT
little-plugger,1.1.4,MIT
load-json-file,1.1.0,MIT
@@ -980,7 +982,7 @@ loggly,1.1.1,MIT
loglevel,1.4.1,MIT
lograge,0.5.1,MIT
longest,1.0.1,MIT
-loofah,2.0.3,MIT
+loofah,2.2.2,MIT
loose-envify,1.3.1,MIT
loud-rejection,1.6.0,MIT
lowercase-keys,1.0.0,MIT
@@ -994,7 +996,7 @@ mailgun-js,0.7.15,MIT
make-dir,1.0.0,MIT
map-cache,0.2.2,MIT
map-obj,1.0.1,MIT
-map-stream,0.1.0,Unknown
+map-stream,0.1.0,UNKNOWN
map-visit,1.0.0,MIT
marked,0.3.12,MIT
match-at,0.1.1,MIT
@@ -1022,7 +1024,7 @@ mime-types-data,3.2016.0521,MIT
mimemagic,0.3.0,MIT
mimic-fn,1.1.0,MIT
mimic-response,1.0.0,MIT
-mini_mime,0.1.4,MIT
+mini_mime,1.0.0,MIT
mini_portile2,2.3.0,MIT
minimalistic-assert,1.0.0,ISC
minimalistic-crypto-utils,1.0.1,MIT
@@ -1047,7 +1049,7 @@ multi_xml,0.6.0,MIT
multicast-dns,6.1.1,MIT
multicast-dns-service-types,1.1.0,MIT
multipart-post,2.0.0,MIT
-mustermann,1.0.0,MIT
+mustermann,1.0.2,MIT
mustermann-grape,1.0.0,MIT
mute-stream,0.0.5,ISC
mute-stream,0.0.7,ISC
@@ -1058,7 +1060,7 @@ nanomatch,1.2.9,MIT
natural-compare,1.4.0,MIT
negotiator,0.6.1,MIT
net-ldap,0.16.0,MIT
-net-ssh,4.1.0,MIT
+net-ssh,4.2.0,MIT
netmask,1.0.6,MIT
netrc,0.11.0,MIT
node-forge,0.6.33,New BSD
@@ -1088,7 +1090,7 @@ null-check,1.0.0,MIT
num2fraction,1.2.2,MIT
number-is-nan,1.0.1,MIT
numerizer,0.1.1,MIT
-oauth,0.5.1,MIT
+oauth,0.5.4,MIT
oauth-sign,0.8.2,Apache 2.0
oauth2,1.4.0,MIT
object-assign,4.1.1,MIT
@@ -1099,25 +1101,25 @@ object-visit,1.0.1,MIT
object.omit,2.0.1,MIT
object.pick,1.3.0,MIT
obuf,1.1.1,MIT
-octokit,4.6.2,MIT
-oj,2.17.5,MIT
-omniauth,1.4.2,MIT
-omniauth-auth0,1.4.1,MIT
+octokit,4.8.0,MIT
+omniauth,1.8.1,MIT
+omniauth-auth0,2.0.0,MIT
omniauth-authentiq,0.3.1,MIT
omniauth-azure-oauth2,0.0.9,MIT
omniauth-cas3,1.1.4,MIT
omniauth-facebook,4.0.0,MIT
omniauth-github,1.1.2,MIT
omniauth-gitlab,1.0.2,MIT
-omniauth-google-oauth2,0.5.2,MIT
+omniauth-google-oauth2,0.5.3,MIT
+omniauth-jwt,0.0.2,MIT
omniauth-kerberos,0.3.0,MIT
omniauth-multipassword,0.4.2,MIT
omniauth-oauth,1.1.0,MIT
-omniauth-oauth2,1.4.0,MIT
+omniauth-oauth2,1.5.0,MIT
omniauth-oauth2-generic,0.2.2,MIT
-omniauth-saml,1.7.0,MIT
+omniauth-saml,1.10.0,MIT
omniauth-shibboleth,1.2.1,MIT
-omniauth-twitter,1.2.1,MIT
+omniauth-twitter,1.4.0,MIT
omniauth_crowd,2.2.3,MIT
on-finished,2.3.0,MIT
on-headers,1.0.1,MIT
@@ -1181,7 +1183,6 @@ pause-stream,0.0.11,Apache 2.0
pbkdf2,3.0.14,MIT
peek,1.0.1,MIT
peek-gc,0.0.2,MIT
-peek-host,1.0.0,MIT
peek-mysql2,1.1.0,MIT
peek-performance_bar,1.3.1,MIT
peek-pg,1.3.0,MIT
@@ -1248,8 +1249,8 @@ premailer,1.10.4,New BSD
premailer-rails,1.9.7,MIT
prepend-http,1.0.4,MIT
preserve,0.2.0,MIT
+prettier,1.11.1,MIT
prettier,1.8.2,MIT
-prettier,1.9.2,MIT
prismjs,1.6.0,MIT
private,0.1.8,MIT
process,0.11.10,MIT
@@ -1283,18 +1284,18 @@ querystring,0.2.0,MIT
querystring-es3,0.2.1,MIT
querystringify,0.0.4,MIT
querystringify,1.0.0,MIT
-rack,1.6.8,MIT
+rack,1.6.9,MIT
rack-accept,0.4.5,MIT
rack-attack,4.4.1,MIT
rack-cors,1.0.2,MIT
rack-oauth2,1.2.3,MIT
-rack-protection,1.5.3,MIT
+rack-protection,2.0.1,MIT
rack-proxy,0.6.0,MIT
rack-test,0.6.3,MIT
rails,4.2.10,MIT
rails-deprecated_sanitizer,1.0.3,MIT
-rails-dom-testing,1.0.8,MIT
-rails-html-sanitizer,1.0.3,MIT
+rails-dom-testing,1.0.9,MIT
+rails-html-sanitizer,1.0.4,MIT
rails-i18n,4.0.9,MIT
railties,4.2.10,MIT
rainbow,2.2.2,MIT
@@ -1331,7 +1332,7 @@ readdirp,2.1.0,MIT
readline2,1.0.1,MIT
recaptcha,3.0.0,MIT
rechoir,0.6.2,MIT
-recursive-open-struct,1.0.0,MIT
+recursive-open-struct,1.0.5,MIT
recursive-readdir,2.2.1,MIT
redcarpet,3.4.0,MIT
redent,1.0.0,MIT
@@ -1383,7 +1384,7 @@ resolve-from,1.0.1,MIT
resolve-from,3.0.0,MIT
resolve-url,0.2.1,MIT
responders,2.3.0,MIT
-rest-client,2.0.0,MIT
+rest-client,2.0.2,MIT
restore-cursor,1.0.1,MIT
restore-cursor,2.0.0,MIT
ret,0.1.15,MIT
@@ -1399,13 +1400,13 @@ rqrcode,0.7.0,MIT
rqrcode-rails3,0.1.7,MIT
ruby-enum,0.7.2,MIT
ruby-fogbugz,0.2.1,MIT
-ruby-prof,0.16.2,Simplified BSD
-ruby-saml,1.4.1,MIT
+ruby-prof,0.17.0,Simplified BSD
+ruby-saml,1.7.2,MIT
ruby_parser,3.9.0,MIT
rubyntlm,0.6.2,MIT
rubypants,0.2.0,BSD
rufus-scheduler,3.4.0,MIT
-rugged,0.26.0,MIT
+rugged,0.27.0,MIT
run-async,0.1.0,MIT
run-async,2.3.0,MIT
run-queue,1.0.3,ISC
@@ -1436,7 +1437,7 @@ semver,5.3.0,ISC
semver,5.5.0,ISC
semver-diff,2.1.0,MIT
send,0.16.1,MIT
-sentry-raven,2.5.3,Apache 2.0
+sentry-raven,2.7.2,Apache 2.0
serialize-javascript,1.4.0,New BSD
serve-index,1.9.0,MIT
serve-static,1.13.1,MIT
@@ -1507,9 +1508,9 @@ srcset,1.0.0,MIT
sshkey,1.9.0,MIT
sshpk,1.13.1,MIT
ssri,5.2.4,ISC
-state_machines,0.4.0,MIT
-state_machines-activemodel,0.4.0,MIT
-state_machines-activerecord,0.4.0,MIT
+state_machines,0.5.0,MIT
+state_machines-activemodel,0.5.1,MIT
+state_machines-activerecord,0.5.1,MIT
static-extend,0.1.2,MIT
statuses,1.3.1,MIT
statuses,1.4.0,MIT
@@ -1603,7 +1604,7 @@ tweetnacl,0.14.5,Unlicense
type-check,0.3.2,MIT
type-is,1.6.16,MIT
typedarray,0.0.6,MIT
-tzinfo,1.2.4,MIT
+tzinfo,1.2.5,MIT
u2f,0.2.1,MIT
uber,0.1.0,MIT
uglifier,2.7.2,MIT
@@ -1618,7 +1619,7 @@ undefsafe,2.0.2,MIT
underscore,1.7.0,MIT
underscore,1.8.3,MIT
unf,0.1.4,BSD
-unf_ext,0.0.7.4,MIT
+unf_ext,0.0.7.5,MIT
unicorn,5.1.0,ruby
unicorn-worker-killer,0.4.4,ruby
union-value,1.0.0,MIT
diff --git a/yarn.lock b/yarn.lock
index dfa98d0cad1..fde06adf67e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1863,9 +1863,9 @@ combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"
-commander@^2.13.0, commander@^2.9.0:
- version "2.14.1"
- resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa"
+commander@^2.13.0, commander@^2.15.1, commander@^2.9.0:
+ version "2.15.1"
+ resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
commondir@^1.0.1:
version "1.0.1"