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:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-08-09 21:12:28 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-08-09 21:12:28 +0300
commit92c34e56b6f81ba46978ca38c579eb916e4953d5 (patch)
tree53a88ba603e4a4ba75627f3b60c15cd09c75f4e6
parentc7b01b0c594a833a52dabc4982238f23904a2ff9 (diff)
parente17e41e409c7a2db9b0496f4d88807d252eb8bf2 (diff)
Merge branch 'refactor-builds-creation-service' into pipeline-hooks-without-touch
-rw-r--r--.rubocop.yml12
-rw-r--r--.rubocop_todo.yml7
-rw-r--r--CHANGELOG29
-rw-r--r--CONTRIBUTING.md6
-rw-r--r--Gemfile8
-rw-r--r--Gemfile.lock16
-rw-r--r--app/assets/javascripts/application.js6
-rw-r--r--app/assets/javascripts/diff.js29
-rw-r--r--app/assets/javascripts/dispatcher.js4
-rw-r--r--app/assets/javascripts/gl_dropdown.js46
-rw-r--r--app/assets/javascripts/lib/utils/datetime_utility.js38
-rw-r--r--app/assets/javascripts/project.js10
-rw-r--r--app/assets/javascripts/protected_branch_access_dropdown.js.es624
-rw-r--r--app/assets/javascripts/protected_branch_create.js.es656
-rw-r--r--app/assets/javascripts/protected_branch_dropdown.js.es675
-rw-r--r--app/assets/javascripts/protected_branch_edit.js.es661
-rw-r--r--app/assets/javascripts/protected_branch_edit_list.js.es617
-rw-r--r--app/assets/javascripts/protected_branch_select.js72
-rw-r--r--app/assets/javascripts/protected_branches_access_select.js.es663
-rw-r--r--app/assets/javascripts/users_select.js38
-rw-r--r--app/assets/stylesheets/framework/dropdowns.scss8
-rw-r--r--app/assets/stylesheets/framework/lists.scss11
-rw-r--r--app/assets/stylesheets/framework/panels.scss5
-rw-r--r--app/assets/stylesheets/framework/variables.scss1
-rw-r--r--app/assets/stylesheets/pages/groups.scss8
-rw-r--r--app/assets/stylesheets/pages/projects.scss31
-rw-r--r--app/controllers/profiles/passwords_controller.rb1
-rw-r--r--app/controllers/projects/blob_controller.rb2
-rw-r--r--app/controllers/projects/deploy_keys_controller.rb20
-rw-r--r--app/controllers/projects/git_http_controller.rb39
-rw-r--r--app/controllers/registrations_controller.rb2
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/helpers/avatars_helper.rb2
-rw-r--r--app/helpers/diff_helper.rb39
-rw-r--r--app/helpers/explore_helper.rb2
-rw-r--r--app/helpers/search_helper.rb2
-rw-r--r--app/models/ability.rb4
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--app/models/concerns/faster_cache_keys.rb16
-rw-r--r--app/models/issue.rb1
-rw-r--r--app/models/members/project_member.rb6
-rw-r--r--app/models/merge_request_diff.rb2
-rw-r--r--app/models/note.rb1
-rw-r--r--app/models/project.rb11
-rw-r--r--app/models/project_team.rb2
-rw-r--r--app/models/repository.rb6
-rw-r--r--app/services/projects/enable_deploy_key_service.rb17
-rw-r--r--app/views/admin/application_settings/_form.html.haml9
-rw-r--r--app/views/notify/new_issue_email.text.erb2
-rw-r--r--app/views/notify/new_merge_request_email.text.erb2
-rw-r--r--app/views/projects/blob/diff.html.haml34
-rw-r--r--app/views/projects/ci/pipelines/_pipeline.html.haml2
-rw-r--r--app/views/projects/diffs/_content.html.haml2
-rw-r--r--app/views/projects/diffs/_diffs.html.haml2
-rw-r--r--app/views/projects/diffs/_line.html.haml3
-rw-r--r--app/views/projects/diffs/_match_line.html.haml7
-rw-r--r--app/views/projects/diffs/_parallel_view.html.haml10
-rw-r--r--app/views/projects/diffs/_text_file.html.haml5
-rw-r--r--app/views/projects/merge_requests/_show.html.haml2
-rw-r--r--app/views/projects/protected_branches/_branches_list.html.haml50
-rw-r--r--app/views/projects/protected_branches/_create_protected_branch.html.haml36
-rw-r--r--app/views/projects/protected_branches/_dropdown.html.haml12
-rw-r--r--app/views/projects/protected_branches/_protected_branch.html.haml17
-rw-r--r--app/views/projects/protected_branches/index.html.haml36
-rw-r--r--app/views/shared/web_hooks/_form.html.haml2
-rw-r--r--app/workers/post_receive.rb4
-rw-r--r--config/initializers/devise.rb3
-rw-r--r--db/fixtures/development/14_builds.rb45
-rw-r--r--db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb4
-rw-r--r--db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb4
-rw-r--r--db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb2
-rw-r--r--db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb2
-rw-r--r--db/migrate/20160804150737_add_timestamps_to_members_again.rb21
-rw-r--r--db/schema.rb2
-rw-r--r--doc/administration/build_artifacts.md90
-rw-r--r--doc/administration/container_registry.md3
-rw-r--r--doc/administration/custom_hooks.md3
-rw-r--r--doc/administration/housekeeping.md2
-rw-r--r--doc/administration/raketasks/project_import_export.md15
-rw-r--r--doc/administration/repository_checks.md5
-rw-r--r--doc/api/README.md2
-rw-r--r--doc/api/award_emoji.md4
-rw-r--r--doc/api/deploy_keys.md48
-rw-r--r--doc/api/repository_files.md16
-rw-r--r--doc/api/todos.md2
-rw-r--r--doc/ci/README.md2
-rw-r--r--doc/ci/build_artifacts/README.md177
-rw-r--r--doc/ci/build_artifacts/img/build_artifacts_browser.pngbin82102 -> 0 bytes
-rw-r--r--doc/ci/build_artifacts/img/build_artifacts_browser_button.pngbin7230 -> 0 bytes
-rw-r--r--doc/ci/triggers/README.md2
-rw-r--r--doc/container_registry/README.md5
-rw-r--r--doc/development/README.md1
-rw-r--r--doc/development/doc_styleguide.md75
-rw-r--r--doc/development/newlines_styleguide.md102
-rw-r--r--doc/development/rake_tasks.md30
-rw-r--r--doc/development/what_requires_downtime.md153
-rw-r--r--doc/monitoring/health_check.md2
-rw-r--r--doc/user/admin_area/settings/continuous_integration.md20
-rw-r--r--doc/user/admin_area/settings/img/admin_area_maximum_artifacts_size.pngbin0 -> 6227 bytes
-rw-r--r--doc/user/admin_area/settings/img/admin_area_settings_button.pngbin0 -> 9184 bytes
-rw-r--r--doc/user/project/builds/artifacts.md104
-rw-r--r--doc/user/project/builds/img/build_artifacts_browser.pngbin0 -> 8365 bytes
-rw-r--r--doc/user/project/builds/img/build_artifacts_browser_button.pngbin0 -> 11041 bytes
-rw-r--r--doc/user/project/builds/img/build_artifacts_builds_page.pngbin0 -> 55625 bytes
-rw-r--r--doc/user/project/builds/img/build_artifacts_pipelines_page.pngbin0 -> 73038 bytes
-rw-r--r--doc/user/project/labels.md12
-rw-r--r--doc/user/project/protected_branches.md3
-rw-r--r--doc/user/project/settings/import_export.md25
-rw-r--r--doc/web_hooks/web_hooks.md4
-rw-r--r--doc/workflow/award_emoji.md6
-rw-r--r--doc/workflow/cherry_pick_changes.md3
-rw-r--r--doc/workflow/file_finder.md2
-rw-r--r--doc/workflow/revert_changes.md2
-rw-r--r--doc/workflow/todos.md2
-rw-r--r--doc/workflow/web_editor.md3
-rw-r--r--features/project/merge_requests.feature9
-rw-r--r--features/steps/project/merge_requests.rb3
-rw-r--r--lib/api/api.rb6
-rw-r--r--lib/api/deploy_keys.rb104
-rw-r--r--lib/banzai/filter/relative_link_filter.rb3
-rw-r--r--lib/banzai/filter/video_link_filter.rb3
-rw-r--r--lib/ci/static_model.rb49
-rw-r--r--lib/gitlab/ci/config/node/validatable.rb10
-rw-r--r--lib/gitlab/closing_issue_extractor.rb4
-rw-r--r--lib/gitlab/git_access.rb2
-rw-r--r--lib/gitlab/git_post_receive.rb1
-rw-r--r--lib/gitlab/import_export/avatar_restorer.rb1
-rw-r--r--lib/gitlab/import_export/members_mapper.rb13
-rw-r--r--lib/gitlab/ldap/access.rb2
-rw-r--r--lib/gitlab/ldap/adapter.rb2
-rw-r--r--lib/gitlab/popen.rb2
-rw-r--r--lib/gitlab/redis.rb2
-rw-r--r--lib/gitlab/user_access.rb2
-rw-r--r--lib/support/nginx/gitlab7
-rw-r--r--lib/support/nginx/gitlab-ssl7
-rw-r--r--lib/tasks/gitlab/bulk_add_permission.rake12
-rw-r--r--lib/tasks/gitlab/web_hook.rake4
-rw-r--r--spec/controllers/admin/users_controller_spec.rb2
-rw-r--r--spec/controllers/application_controller_spec.rb6
-rw-r--r--spec/controllers/groups/avatars_controller_spec.rb2
-rw-r--r--spec/controllers/groups/milestones_controller_spec.rb2
-rw-r--r--spec/controllers/profiles/avatars_controller_spec.rb2
-rw-r--r--spec/controllers/profiles/keys_controller_spec.rb18
-rw-r--r--spec/controllers/projects/avatars_controller_spec.rb2
-rw-r--r--spec/controllers/projects/commit_controller_spec.rb26
-rw-r--r--spec/controllers/projects/commits_controller_spec.rb2
-rw-r--r--spec/controllers/projects/compare_controller_spec.rb8
-rw-r--r--spec/controllers/projects/forks_controller_spec.rb10
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb16
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb12
-rw-r--r--spec/controllers/projects/milestones_controller_spec.rb2
-rw-r--r--spec/controllers/projects/protected_branches_controller_spec.rb2
-rw-r--r--spec/controllers/projects/raw_controller_spec.rb2
-rw-r--r--spec/controllers/projects/services_controller_spec.rb4
-rw-r--r--spec/controllers/projects_controller_spec.rb10
-rw-r--r--spec/factories_spec.rb2
-rw-r--r--spec/features/admin/admin_abuse_reports_spec.rb4
-rw-r--r--spec/features/admin/admin_disables_git_access_protocol_spec.rb1
-rw-r--r--spec/features/admin/admin_hooks_spec.rb6
-rw-r--r--spec/features/admin/admin_projects_spec.rb6
-rw-r--r--spec/features/admin/admin_users_spec.rb28
-rw-r--r--spec/features/atom/dashboard_spec.rb6
-rw-r--r--spec/features/atom/issues_spec.rb4
-rw-r--r--spec/features/atom/users_spec.rb12
-rw-r--r--spec/features/ci_lint_spec.rb2
-rw-r--r--spec/features/commits_spec.rb2
-rw-r--r--spec/features/compare_spec.rb6
-rw-r--r--spec/features/dashboard/label_filter_spec.rb2
-rw-r--r--spec/features/dashboard_issues_spec.rb6
-rw-r--r--spec/features/gitlab_flavored_markdown_spec.rb24
-rw-r--r--spec/features/help_pages_spec.rb2
-rw-r--r--spec/features/issues/award_emoji_spec.rb10
-rw-r--r--spec/features/issues/award_spec.rb8
-rw-r--r--spec/features/issues/bulk_assignment_labels_spec.rb8
-rw-r--r--spec/features/issues/filter_by_labels_spec.rb46
-rw-r--r--spec/features/issues/filter_by_milestone_spec.rb6
-rw-r--r--spec/features/issues/filter_issues_spec.rb38
-rw-r--r--spec/features/issues/issue_sidebar_spec.rb8
-rw-r--r--spec/features/issues/new_branch_button_spec.rb2
-rw-r--r--spec/features/issues/todo_spec.rb4
-rw-r--r--spec/features/issues/update_issues_spec.rb12
-rw-r--r--spec/features/issues_spec.rb16
-rw-r--r--spec/features/login_spec.rb2
-rw-r--r--spec/features/merge_requests/award_spec.rb8
-rw-r--r--spec/features/merge_requests/edit_mr_spec.rb2
-rw-r--r--spec/features/merge_requests/filter_by_milestone_spec.rb6
-rw-r--r--spec/features/merge_requests/merge_when_build_succeeds_spec.rb2
-rw-r--r--spec/features/milestone_spec.rb4
-rw-r--r--spec/features/notes_on_merge_requests_spec.rb12
-rw-r--r--spec/features/participants_autocomplete_spec.rb6
-rw-r--r--spec/features/pipelines_spec.rb10
-rw-r--r--spec/features/profile_spec.rb4
-rw-r--r--spec/features/profiles/password_spec.rb45
-rw-r--r--spec/features/projects/labels/update_prioritization_spec.rb4
-rw-r--r--spec/features/projects/ref_switcher_spec.rb29
-rw-r--r--spec/features/projects_spec.rb8
-rw-r--r--spec/features/protected_branches_spec.rb14
-rw-r--r--spec/features/search_spec.rb18
-rw-r--r--spec/features/todos/todos_spec.rb2
-rw-r--r--spec/features/variables_spec.rb8
-rw-r--r--spec/finders/merge_requests_finder_spec.rb4
-rw-r--r--spec/finders/notes_finder_spec.rb4
-rw-r--r--spec/helpers/application_helper_spec.rb37
-rw-r--r--spec/helpers/blob_helper_spec.rb10
-rw-r--r--spec/helpers/diff_helper_spec.rb94
-rw-r--r--spec/helpers/emails_helper_spec.rb12
-rw-r--r--spec/helpers/events_helper_spec.rb14
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb20
-rw-r--r--spec/helpers/graph_helper_spec.rb2
-rw-r--r--spec/helpers/groups_helper_spec.rb4
-rw-r--r--spec/helpers/issues_helper_spec.rb9
-rw-r--r--spec/helpers/notes_helper_spec.rb2
-rw-r--r--spec/helpers/search_helper_spec.rb2
-rw-r--r--spec/helpers/submodule_helper_spec.rb28
-rw-r--r--spec/helpers/tree_helper_spec.rb4
-rw-r--r--spec/javascripts/datetime_utility_spec.js.coffee31
-rw-r--r--spec/lib/banzai/filter/relative_link_filter_spec.rb5
-rw-r--r--spec/lib/banzai/filter/video_link_filter_spec.rb1
-rw-r--r--spec/lib/ci/charts_spec.rb4
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb18
-rw-r--r--spec/lib/disable_email_interceptor_spec.rb2
-rw-r--r--spec/lib/extracts_path_spec.rb4
-rw-r--r--spec/lib/gitlab/asciidoc_spec.rb4
-rw-r--r--spec/lib/gitlab/auth_spec.rb10
-rw-r--r--spec/lib/gitlab/ci/config/node/validatable_spec.rb4
-rw-r--r--spec/lib/gitlab/closing_issue_extractor_spec.rb11
-rw-r--r--spec/lib/gitlab/git/hook_spec.rb1
-rw-r--r--spec/lib/gitlab/git_access_spec.rb12
-rw-r--r--spec/lib/gitlab/import_export/members_mapper_spec.rb20
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb1
-rw-r--r--spec/lib/gitlab/ldap/access_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/user_spec.rb2
-rw-r--r--spec/lib/gitlab/o_auth/user_spec.rb6
-rw-r--r--spec/lib/gitlab/project_search_results_spec.rb12
-rw-r--r--spec/lib/gitlab/saml/user_spec.rb10
-rw-r--r--spec/lib/gitlab/search_results_spec.rb12
-rw-r--r--spec/lib/gitlab/upgrader_spec.rb6
-rw-r--r--spec/lib/gitlab/user_access_spec.rb52
-rw-r--r--spec/mailers/emails/profile_spec.rb2
-rw-r--r--spec/mailers/notify_spec.rb2
-rw-r--r--spec/models/application_setting_spec.rb22
-rw-r--r--spec/models/broadcast_message_spec.rb6
-rw-r--r--spec/models/build_spec.rb30
-rw-r--r--spec/models/ci/pipeline_spec.rb4
-rw-r--r--spec/models/ci/trigger_spec.rb4
-rw-r--r--spec/models/commit_status_spec.rb12
-rw-r--r--spec/models/concerns/faster_cache_keys_spec.rb17
-rw-r--r--spec/models/concerns/milestoneish_spec.rb36
-rw-r--r--spec/models/concerns/token_authenticatable_spec.rb2
-rw-r--r--spec/models/forked_project_link_spec.rb10
-rw-r--r--spec/models/global_milestone_spec.rb12
-rw-r--r--spec/models/group_spec.rb6
-rw-r--r--spec/models/hooks/project_hook_spec.rb4
-rw-r--r--spec/models/key_spec.rb4
-rw-r--r--spec/models/label_spec.rb4
-rw-r--r--spec/models/legacy_diff_note_spec.rb4
-rw-r--r--spec/models/members/group_member_spec.rb4
-rw-r--r--spec/models/members/project_member_spec.rb6
-rw-r--r--spec/models/merge_request_spec.rb6
-rw-r--r--spec/models/milestone_spec.rb20
-rw-r--r--spec/models/namespace_spec.rb6
-rw-r--r--spec/models/note_spec.rb6
-rw-r--r--spec/models/project_security_spec.rb18
-rw-r--r--spec/models/project_services/asana_service_spec.rb8
-rw-r--r--spec/models/project_services/assembla_service_spec.rb2
-rw-r--r--spec/models/project_services/external_wiki_service_spec.rb2
-rw-r--r--spec/models/project_services/flowdock_service_spec.rb2
-rw-r--r--spec/models/project_services/gemnasium_service_spec.rb2
-rw-r--r--spec/models/project_services/gitlab_issue_tracker_service_spec.rb4
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb38
-rw-r--r--spec/models/project_services/irker_service_spec.rb2
-rw-r--r--spec/models/project_services/jira_service_spec.rb10
-rw-r--r--spec/models/project_services/pushover_service_spec.rb2
-rw-r--r--spec/models/project_services/slack_service/note_message_spec.rb1
-rw-r--r--spec/models/project_services/slack_service/wiki_page_message_spec.rb4
-rw-r--r--spec/models/project_services/slack_service_spec.rb23
-rw-r--r--spec/models/project_spec.rb128
-rw-r--r--spec/models/repository_spec.rb40
-rw-r--r--spec/models/service_spec.rb4
-rw-r--r--spec/models/user_spec.rb26
-rw-r--r--spec/models/wiki_page_spec.rb6
-rw-r--r--spec/requests/api/api_helpers_spec.rb30
-rw-r--r--spec/requests/api/award_emoji_spec.rb6
-rw-r--r--spec/requests/api/branches_spec.rb38
-rw-r--r--spec/requests/api/builds_spec.rb38
-rw-r--r--spec/requests/api/commit_statuses_spec.rb10
-rw-r--r--spec/requests/api/commits_spec.rb40
-rw-r--r--spec/requests/api/deploy_keys.rb38
-rw-r--r--spec/requests/api/deploy_keys_spec.rb160
-rw-r--r--spec/requests/api/files_spec.rb22
-rw-r--r--spec/requests/api/fork_spec.rb12
-rw-r--r--spec/requests/api/group_members_spec.rb34
-rw-r--r--spec/requests/api/groups_spec.rb56
-rw-r--r--spec/requests/api/issues_spec.rb104
-rw-r--r--spec/requests/api/keys_spec.rb6
-rw-r--r--spec/requests/api/labels_spec.rb60
-rw-r--r--spec/requests/api/merge_requests_spec.rb88
-rw-r--r--spec/requests/api/milestones_spec.rb30
-rw-r--r--spec/requests/api/namespaces_spec.rb10
-rw-r--r--spec/requests/api/notes_spec.rb56
-rw-r--r--spec/requests/api/project_hooks_spec.rb36
-rw-r--r--spec/requests/api/project_members_spec.rb34
-rw-r--r--spec/requests/api/project_snippets_spec.rb2
-rw-r--r--spec/requests/api/projects_spec.rb246
-rw-r--r--spec/requests/api/repositories_spec.rb40
-rw-r--r--spec/requests/api/runners_spec.rb98
-rw-r--r--spec/requests/api/services_spec.rb22
-rw-r--r--spec/requests/api/session_spec.rb12
-rw-r--r--spec/requests/api/settings_spec.rb4
-rw-r--r--spec/requests/api/system_hooks_spec.rb20
-rw-r--r--spec/requests/api/tags_spec.rb34
-rw-r--r--spec/requests/api/triggers_spec.rb44
-rw-r--r--spec/requests/api/users_spec.rb227
-rw-r--r--spec/requests/api/variables_spec.rb38
-rw-r--r--spec/requests/ci/api/builds_spec.rb34
-rw-r--r--spec/requests/ci/api/triggers_spec.rb16
-rw-r--r--spec/requests/git_http_spec.rb18
-rw-r--r--spec/services/create_snippet_service_spec.rb4
-rw-r--r--spec/services/event_create_service_spec.rb14
-rw-r--r--spec/services/git_hooks_service_spec.rb6
-rw-r--r--spec/services/git_push_service_spec.rb6
-rw-r--r--spec/services/issues/bulk_update_service_spec.rb2
-rw-r--r--spec/services/issues/close_service_spec.rb4
-rw-r--r--spec/services/issues/update_service_spec.rb8
-rw-r--r--spec/services/merge_requests/close_service_spec.rb4
-rw-r--r--spec/services/merge_requests/create_service_spec.rb2
-rw-r--r--spec/services/merge_requests/merge_request_diff_cache_service_spec.rb1
-rw-r--r--spec/services/merge_requests/merge_service_spec.rb4
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb4
-rw-r--r--spec/services/merge_requests/reopen_service_spec.rb6
-rw-r--r--spec/services/merge_requests/update_service_spec.rb8
-rw-r--r--spec/services/notification_service_spec.rb8
-rw-r--r--spec/services/projects/autocomplete_service_spec.rb14
-rw-r--r--spec/services/projects/create_service_spec.rb6
-rw-r--r--spec/services/projects/enable_deploy_key_service_spec.rb27
-rw-r--r--spec/services/projects/fork_service_spec.rb8
-rw-r--r--spec/services/projects/update_service_spec.rb18
-rw-r--r--spec/services/repair_ldap_blocked_user_service_spec.rb4
-rw-r--r--spec/services/search_service_spec.rb8
-rw-r--r--spec/services/system_note_service_spec.rb12
-rw-r--r--spec/services/test_hook_service_spec.rb2
-rw-r--r--spec/support/select2_helper.rb2
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb14
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb8
-rw-r--r--spec/workers/post_receive_spec.rb6
-rw-r--r--vendor/gitignore/Global/VisualStudioCode.gitignore6
-rw-r--r--vendor/gitlab-ci-yml/Pages/Hexo.gitlab-ci.yml26
-rw-r--r--vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml6
348 files changed, 3543 insertions, 2437 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 556a5d11a39..282f4539f03 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -149,19 +149,19 @@ Style/EmptyLinesAroundAccessModifier:
# Keeps track of empty lines around block bodies.
Style/EmptyLinesAroundBlockBody:
- Enabled: false
+ Enabled: true
# Keeps track of empty lines around class bodies.
Style/EmptyLinesAroundClassBody:
- Enabled: false
+ Enabled: true
# Keeps track of empty lines around module bodies.
Style/EmptyLinesAroundModuleBody:
- Enabled: false
+ Enabled: true
# Keeps track of empty lines around method bodies.
Style/EmptyLinesAroundMethodBody:
- Enabled: false
+ Enabled: true
# Avoid the use of END blocks.
Style/EndBlock:
@@ -373,6 +373,10 @@ Style/SpaceAfterNot:
Style/SpaceAfterSemicolon:
Enabled: true
+# Use space around equals in parameter default
+Style/SpaceAroundEqualsInParameterDefault:
+ Enabled: true
+
# Use a space around keywords if appropriate.
Style/SpaceAroundKeyword:
Enabled: true
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 76ae5952753..20daf1619a7 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -339,13 +339,6 @@ Style/SingleLineBlockParams:
Style/SingleLineMethods:
Enabled: false
-# Offense count: 14
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, SupportedStyles.
-# SupportedStyles: space, no_space
-Style/SpaceAroundEqualsInParameterDefault:
- Enabled: false
-
# Offense count: 119
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
diff --git a/CHANGELOG b/CHANGELOG
index d1bf2df03a0..1689fb3c5f4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,11 +2,14 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.11.0 (unreleased)
- Fix don't pass a local variable called `i` to a partial. !20510 (herminiotorres)
+ - Fix rename `add_users_into_project` and `projects_ids`. !20512 (herminiotorres)
- Fix the title of the toggle dropdown button. !5515 (herminiotorres)
- Improve diff performance by eliminating redundant checks for text blobs
- Convert switch icon into icon font (ClemMakesApps)
+ - API: Endpoints for enabling and disabling deploy keys
- Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell)
- Add support for relative links starting with ./ or / to RelativeLinkFilter (winniehell)
+ - Ignore URLs starting with // in Markdown links !5677 (winniehell)
- Fix CI status icon link underline (ClemMakesApps)
- The Repository class is now instrumented
- Cache the commit author in RequestStore to avoid extra lookups in PostReceive
@@ -18,24 +21,31 @@ v 8.11.0 (unreleased)
- Add "No one can push" as an option for protected branches. !5081
- Improve performance of AutolinkFilter#text_parse by using XPath
- Environments have an url to link to
+ - Update `timeago` plugin to use multiple string/locale settings
- Remove unused images (ClemMakesApps)
- Limit git rev-list output count to one in forced push check
- Clean up unused routes (Josef Strzibny)
+ - Fix issue on empty project to allow developers to only push to protected branches if given permission
- Add green outline to New Branch button. !5447 (winniehell)
+ - Optimize generating of cache keys for issues and notes
- Improve performance of syntax highlighting Markdown code blocks
- Update to gitlab_git 10.4.1 and take advantage of preserved Ref objects
- Remove delay when hitting "Reply..." button on page with a lot of discussions
- Retrieve rendered HTML from cache in one request
- Fix renaming repository when name contains invalid chararacters under project settings
+ - Upgrade Grape from 0.13.0 to 0.15.0. !4601
- Fix devise deprecation warnings.
+ - Update version_sorter and use new interface for faster tag sorting
- Optimize checking if a user has read access to a list of issues !5370
- Nokogiri's various parsing methods are now instrumented
- Add simple identifier to public SSH keys (muteor)
+ - Admin page now references docs instead of a specific file !5600 (AnAverageHuman)
- Add a way to send an email and create an issue based on private personal token. Find the email address from issues page. !3363
- Fix filter input alignment (ClemMakesApps)
- Include old revision in merge request update hooks (Ben Boeckel)
- Add build event color in HipChat messages (David Eisner)
- Make fork counter always clickable. !5463 (winniehell)
+ - Document that webhook secret token is sent in X-Gitlab-Token HTTP header !5664 (lycoperdon)
- Gitlab::Highlight is now instrumented
- All created issues, API or WebUI, can be submitted to Akismet for spam check !5333
- The overhead of instrumented method calls has been reduced
@@ -63,17 +73,25 @@ v 8.11.0 (unreleased)
- Make error pages responsive (Takuya Noguchi)
- Fix skip_repo parameter being ignored when destroying a namespace
- Change requests_profiles resource constraint to catch virtually any file
+ - Bump gitlab_git to lazy load compare commits
- Reduce number of queries made for merge_requests/:id/diffs
- Sensible state specific default sort order for issues and merge requests !5453 (tomb0y)
- Fix RequestProfiler::Middleware error when code is reloaded in development
- Catch what warden might throw when profiling requests to re-throw it
+ - Add description to new_issue email and new_merge_request_email in text/plain content type. !5663 (dixpac)
- Speed up and reduce memory usage of Commit#repo_changes, Repository#expire_avatar_cache and IrkerWorker
+ - Add unfold links for Side-by-Side view. !5415 (Tim Masliuchenko)
+ - Adds support for pending invitation project members importing projects
+ - Update devise initializer to turn on changed password notification emails. !5648 (tombell)
+ - Avoid to show the original password field when password is automatically set. !5712 (duduribeiro)
-v 8.10.4 (unreleased)
- - Fix Import/Export error checking versions
+v 8.10.5 (unreleased)
-v 8.10.4 (unreleased)
- - Fix Import/Export project import not working in HA mode
+v 8.10.4
+ - Don't close referenced upstream issues from a forked project.
+ - Fixes issue with dropdowns `enter` key not working correctly. !5544
+ - Fix Import/Export project import not working in HA mode. !5618
+ - Fix Import/Export error checking versions. !5638
v 8.10.3
- Fix Import/Export issue importing milestones and labels not associated properly. !5426
@@ -162,6 +180,9 @@ v 8.10.0
- Fix check for New Branch button on Issue page. !4630 (winniehell)
- Fix GFM autocomplete not working on wiki pages
- Fixed enter key not triggering click on first row when searching in a dropdown
+ - Updated dropdowns in issuable form to use new GitLab dropdown style
+ - Make images fit to the size of the viewport !4810
+ - Fix check for New Branch button on Issue page !4630 (winniehell)
- Fix MR-auto-close text added to description. !4836
- Support U2F devices in Firefox. !5177
- Fix issue, preventing users w/o push access to sort tags. !5105 (redetection)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2f522c1e39a..fbc8e15bebf 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -336,6 +336,10 @@ request is as follows:
1. If your code creates new files on disk please read the
[shared files guidelines](doc/development/shared_files.md).
1. When writing commit messages please follow [these](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) [guidelines](http://chris.beams.io/posts/git-commit/).
+1. If your merge request adds one or more migrations, make sure to execute all
+ migrations on a fresh database before the MR is reviewed. If the review leads
+ to large changes in the MR, do this again once the review is complete.
+1. For more complex migrations, write tests.
The **official merge window** is in the beginning of the month from the 1st to
the 7th day of the month. This is the best time to submit an MR and get
@@ -461,6 +465,7 @@ merge request:
- multi-line method chaining style **Option B**: dot `.` on previous line
- string literal quoting style **Option A**: single quoted by default
1. [Rails](https://github.com/bbatsov/rails-style-guide)
+1. [Newlines styleguide][newlines-styleguide]
1. [Testing](doc/development/testing.md)
1. [JavaScript (ES6)](https://github.com/airbnb/javascript)
1. [JavaScript (ES5)](https://github.com/airbnb/javascript/tree/master/es5)
@@ -533,6 +538,7 @@ available at [http://contributor-covenant.org/version/1/1/0/](http://contributor
[rss-naming]: https://github.com/bbatsov/ruby-style-guide/blob/master/README.md#naming
[doc-styleguide]: doc/development/doc_styleguide.md "Documentation styleguide"
[scss-styleguide]: doc/development/scss_styleguide.md "SCSS styleguide"
+[newlines-styleguide]: doc/development/newlines_styleguide.md "Newlines styleguide"
[gitlab-design]: https://gitlab.com/gitlab-org/gitlab-design
[free Antetype viewer (Mac OSX only)]: https://itunes.apple.com/us/app/antetype-viewer/id824152298?mt=12
[`gitlab8.atype` file]: https://gitlab.com/gitlab-org/gitlab-design/tree/master/current/
diff --git a/Gemfile b/Gemfile
index 16f24553ed1..91f4f20215f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -53,7 +53,7 @@ gem 'browser', '~> 2.2'
# Extracting information from a git repository
# Provide access to Gitlab::Git library
-gem 'gitlab_git', '~> 10.4.3'
+gem 'gitlab_git', '~> 10.4.5'
# LDAP Auth
# GitLab fork with several improvements to original library. For full list of changes
@@ -69,7 +69,7 @@ gem 'gollum-rugged_adapter', '~> 0.4.2', require: false
gem 'github-linguist', '~> 4.7.0', require: 'linguist'
# API
-gem 'grape', '~> 0.13.0'
+gem 'grape', '~> 0.15.0'
gem 'grape-entity', '~> 0.4.2'
gem 'rack-cors', '~> 0.4.0', require: 'rack/cors'
@@ -154,7 +154,7 @@ gem 'settingslogic', '~> 2.0.9'
# Misc
-gem 'version_sorter', '~> 2.0.0'
+gem 'version_sorter', '~> 2.1.0'
# Cache
gem 'redis-rails', '~> 4.0.0'
@@ -326,7 +326,7 @@ group :production do
gem 'gitlab_meta', '7.0'
end
-gem 'newrelic_rpm', '~> 3.14'
+gem 'newrelic_rpm', '~> 3.16'
gem 'octokit', '~> 4.3.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 866f5014847..43ed6081274 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -278,7 +278,7 @@ GEM
diff-lcs (~> 1.1)
mime-types (>= 1.16, < 3)
posix-spawn (~> 0.3)
- gitlab_git (10.4.3)
+ gitlab_git (10.4.5)
activesupport (~> 4.0)
charlock_holmes (~> 0.7.3)
github-linguist (~> 4.7.0)
@@ -308,7 +308,7 @@ GEM
json
multi_json
request_store (>= 1.0)
- grape (0.13.0)
+ grape (0.15.0)
activesupport
builder
hashie (>= 2.1.0)
@@ -404,7 +404,7 @@ GEM
nested_form (0.3.2)
net-ldap (0.12.1)
net-ssh (3.0.1)
- newrelic_rpm (3.14.1.311)
+ newrelic_rpm (3.16.0.318)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
@@ -778,7 +778,7 @@ GEM
uniform_notifier (1.10.0)
uuid (2.3.8)
macaddr (~> 1.0)
- version_sorter (2.0.0)
+ version_sorter (2.1.0)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
@@ -870,13 +870,13 @@ DEPENDENCIES
github-linguist (~> 4.7.0)
github-markup (~> 1.4)
gitlab-flowdock-git-hook (~> 1.0.1)
- gitlab_git (~> 10.4.3)
+ gitlab_git (~> 10.4.5)
gitlab_meta (= 7.0)
gitlab_omniauth-ldap (~> 1.2.1)
gollum-lib (~> 4.2)
gollum-rugged_adapter (~> 0.4.2)
gon (~> 6.1.0)
- grape (~> 0.13.0)
+ grape (~> 0.15.0)
grape-entity (~> 0.4.2)
hamlit (~> 2.5)
health_check (~> 2.1.0)
@@ -902,7 +902,7 @@ DEPENDENCIES
mysql2 (~> 0.3.16)
nested_form (~> 0.3.2)
net-ssh (~> 3.0.1)
- newrelic_rpm (~> 3.14)
+ newrelic_rpm (~> 3.16)
nokogiri (~> 1.6.7, >= 1.6.7.2)
oauth2 (~> 1.2.0)
octokit (~> 4.3.0)
@@ -989,7 +989,7 @@ DEPENDENCIES
unf (~> 0.1.4)
unicorn (~> 4.9.0)
unicorn-worker-killer (~> 0.4.2)
- version_sorter (~> 2.0.0)
+ version_sorter (~> 2.1.0)
virtus (~> 1.0.1)
vmstat (~> 2.1.1)
web-console (~> 2.0)
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 127e568adc9..f1aab067351 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -287,7 +287,7 @@
$('.page-with-sidebar').toggleClass('page-sidebar-collapsed page-sidebar-expanded').removeClass('page-sidebar-pinned');
$('.navbar-fixed-top').removeClass('header-pinned-nav');
}
- return $document.off('click', '.js-nav-pin').on('click', '.js-nav-pin', function(e) {
+ $document.off('click', '.js-nav-pin').on('click', '.js-nav-pin', function(e) {
var $page, $pinBtn, $tooltip, $topNav, doPinNav, tooltipText;
e.preventDefault();
$pinBtn = $(e.currentTarget);
@@ -315,6 +315,8 @@
$tooltip.find('.tooltip-inner').text(tooltipText);
return $pinBtn.attr('title', tooltipText).tooltip('fixTitle');
});
- });
+ // Custom time ago
+ gl.utils.shortTimeAgo($('.js-short-timeago'));
+ });
}).call(this);
diff --git a/app/assets/javascripts/diff.js b/app/assets/javascripts/diff.js
index 298f3852085..3dd7ceba92f 100644
--- a/app/assets/javascripts/diff.js
+++ b/app/assets/javascripts/diff.js
@@ -10,7 +10,7 @@
$(document).off('click', '.js-unfold');
$(document).on('click', '.js-unfold', (function(_this) {
return function(event) {
- var line_number, link, offset, old_line, params, prev_new_line, prev_old_line, ref, ref1, since, target, to, unfold, unfoldBottom;
+ var line_number, link, file, offset, old_line, params, prev_new_line, prev_old_line, ref, ref1, since, target, to, unfold, unfoldBottom;
target = $(event.target);
unfoldBottom = target.hasClass('js-unfold-bottom');
unfold = true;
@@ -31,14 +31,16 @@
unfold = false;
}
}
- link = target.parents('.diff-file').attr('data-blob-diff-path');
+ file = target.parents('.diff-file');
+ link = file.data('blob-diff-path');
params = {
since: since,
to: to,
bottom: unfoldBottom,
offset: offset,
unfold: unfold,
- indent: 1
+ indent: 1,
+ view: file.data('view')
};
return $.get(link, params, function(response) {
return target.parent().replaceWith(response);
@@ -48,26 +50,13 @@
}
Diff.prototype.lineNumbers = function(line) {
- var i, l, len, line_number, line_numbers, lines, results;
if (!line.children().length) {
return [0, 0];
}
- lines = line.children().slice(0, 2);
- line_numbers = (function() {
- var i, len, results;
- results = [];
- for (i = 0, len = lines.length; i < len; i++) {
- l = lines[i];
- results.push($(l).attr('data-linenumber'));
- }
- return results;
- })();
- results = [];
- for (i = 0, len = line_numbers.length; i < len; i++) {
- line_number = line_numbers[i];
- results.push(parseInt(line_number));
- }
- return results;
+
+ return line.find('.diff-line-num').map(function() {
+ return parseInt($(this).data('linenumber'));
+ });
};
return Diff;
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js
index 9e6901962c6..20f2b1d69b5 100644
--- a/app/assets/javascripts/dispatcher.js
+++ b/app/assets/javascripts/dispatcher.js
@@ -173,8 +173,8 @@
new Search();
break;
case 'projects:protected_branches:index':
- new ProtectedBranchesAccessSelect($(".new_protected_branch"), false, true);
- new ProtectedBranchesAccessSelect($(".protected-branches-list"), true, false);
+ new gl.ProtectedBranchCreate();
+ new gl.ProtectedBranchEditList();
break;
}
switch (path.first()) {
diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js
index c5d92831fbe..d3394fae3f9 100644
--- a/app/assets/javascripts/gl_dropdown.js
+++ b/app/assets/javascripts/gl_dropdown.js
@@ -28,38 +28,43 @@
};
})(this));
timeout = "";
- this.input.on("keyup", (function(_this) {
- return function(e) {
+ this.input
+ .on('keydown', function (e) {
+ var keyCode = e.which;
+
+ if (keyCode === 13) {
+ e.preventDefault()
+ }
+ })
+ .on('keyup', function(e) {
var keyCode;
keyCode = e.which;
if (ARROW_KEY_CODES.indexOf(keyCode) >= 0) {
return;
}
- if (_this.input.val() !== "" && !$inputContainer.hasClass(HAS_VALUE_CLASS)) {
+ if (this.input.val() !== "" && !$inputContainer.hasClass(HAS_VALUE_CLASS)) {
$inputContainer.addClass(HAS_VALUE_CLASS);
- } else if (_this.input.val() === "" && $inputContainer.hasClass(HAS_VALUE_CLASS)) {
+ } else if (this.input.val() === "" && $inputContainer.hasClass(HAS_VALUE_CLASS)) {
$inputContainer.removeClass(HAS_VALUE_CLASS);
}
if (keyCode === 13) {
return false;
}
- if (_this.options.remote) {
+ if (this.options.remote) {
clearTimeout(timeout);
return timeout = setTimeout(function() {
- var blur_field;
- blur_field = _this.shouldBlur(keyCode);
- if (blur_field && _this.filterInputBlur) {
- _this.input.blur();
+ var blurField = this.shouldBlur(keyCode);
+ if (blurField && this.filterInputBlur) {
+ this.input.blur();
}
- return _this.options.query(_this.input.val(), function(data) {
- return _this.options.callback(data);
- });
- }, 250);
+ return this.options.query(this.input.val(), function(data) {
+ return this.options.callback(data);
+ }.bind(this));
+ }.bind(this), 250);
} else {
- return _this.filter(_this.input.val());
+ return this.filter(this.input.val());
}
- };
- })(this));
+ }.bind(this));
}
GitLabDropdownFilter.prototype.shouldBlur = function(keyCode) {
@@ -382,6 +387,7 @@
GitLabDropdown.prototype.opened = function() {
var contentHtml;
+ currentIndex = -1;
this.addArrowKeyEvent();
if (this.options.setIndeterminateIds) {
this.options.setIndeterminateIds.call(this);
@@ -601,7 +607,7 @@
return this.dropdown.before($input);
};
- GitLabDropdown.prototype.selectRowAtIndex = function(e, index) {
+ GitLabDropdown.prototype.selectRowAtIndex = function(index) {
var $el, selector;
selector = ".dropdown-content li:not(.divider,.dropdown-header,.separator):eq(" + index + ") a";
if (this.dropdown.find(".dropdown-toggle-page").length) {
@@ -609,8 +615,6 @@
}
$el = $(selector, this.dropdown);
if ($el.length) {
- e.preventDefault();
- e.stopImmediatePropagation();
return $el.first().trigger('click');
}
};
@@ -619,7 +623,7 @@
var $input, ARROW_KEY_CODES, selector;
ARROW_KEY_CODES = [38, 40];
$input = this.dropdown.find(".dropdown-input-field");
- selector = '.dropdown-content li:not(.divider,.dropdown-header,.separator)';
+ selector = '.dropdown-content li:not(.divider,.dropdown-header,.separator):visible';
if (this.dropdown.find(".dropdown-toggle-page").length) {
selector = ".dropdown-page-one " + selector;
}
@@ -647,7 +651,7 @@
return false;
}
if (currentKeyCode === 13 && currentIndex !== -1) {
- return _this.selectRowAtIndex(e, currentIndex);
+ return _this.selectRowAtIndex($('.is-focused', _this.dropdown).closest('li').index() - 1);
}
};
})(this));
diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js
index e817261f210..10afa7e4329 100644
--- a/app/assets/javascripts/lib/utils/datetime_utility.js
+++ b/app/assets/javascripts/lib/utils/datetime_utility.js
@@ -8,13 +8,16 @@
base.utils = {};
}
w.gl.utils.days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
+
w.gl.utils.formatDate = function(datetime) {
return dateFormat(datetime, 'mmm d, yyyy h:MMtt Z');
};
+
w.gl.utils.getDayName = function(date) {
return this.days[date.getDay()];
};
- return w.gl.utils.localTimeAgo = function($timeagoEls, setTimeago) {
+
+ w.gl.utils.localTimeAgo = function($timeagoEls, setTimeago) {
if (setTimeago == null) {
setTimeago = true;
}
@@ -31,6 +34,39 @@
});
}
};
+
+ w.gl.utils.shortTimeAgo = function($el) {
+ var shortLocale, tmpLocale;
+ shortLocale = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: 'ago',
+ suffixFromNow: 'from now',
+ seconds: '1 min',
+ minute: '1 min',
+ minutes: '%d mins',
+ hour: '1 hr',
+ hours: '%d hrs',
+ day: '1 day',
+ days: '%d days',
+ month: '1 month',
+ months: '%d months',
+ year: '1 year',
+ years: '%d years',
+ wordSeparator: ' ',
+ numbers: []
+ };
+ tmpLocale = $.timeago.settings.strings;
+ $el.each(function(el) {
+ var $el1;
+ $el1 = $(this);
+ return $el1.attr('title', gl.utils.formatDate($el.attr('datetime')));
+ });
+ $.timeago.settings.strings = shortLocale;
+ $el.timeago();
+ $.timeago.settings.strings = tmpLocale;
+ };
+
})(window);
}).call(this);
diff --git a/app/assets/javascripts/project.js b/app/assets/javascripts/project.js
index e6663177161..b97f6d22715 100644
--- a/app/assets/javascripts/project.js
+++ b/app/assets/javascripts/project.js
@@ -89,8 +89,14 @@
toggleLabel: function(obj, $el) {
return $el.text().trim();
},
- clicked: function(e) {
- return $dropdown.closest('form').submit();
+ clicked: function(selected, $el, e) {
+ e.preventDefault()
+ if ($('input[name="ref"]').length) {
+ var $form = $dropdown.closest('form'),
+ action = $form.attr('action'),
+ divider = action.indexOf('?') < 0 ? '?' : '&';
+ Turbolinks.visit(action + '' + divider + '' + $form.serialize());
+ }
}
});
});
diff --git a/app/assets/javascripts/protected_branch_access_dropdown.js.es6 b/app/assets/javascripts/protected_branch_access_dropdown.js.es6
new file mode 100644
index 00000000000..2fbb088fa04
--- /dev/null
+++ b/app/assets/javascripts/protected_branch_access_dropdown.js.es6
@@ -0,0 +1,24 @@
+(global => {
+ global.gl = global.gl || {};
+
+ gl.ProtectedBranchAccessDropdown = class {
+ constructor(options) {
+ const { $dropdown, data, onSelect } = options;
+
+ $dropdown.glDropdown({
+ data: data,
+ selectable: true,
+ inputId: $dropdown.data('input-id'),
+ fieldName: $dropdown.data('field-name'),
+ toggleLabel(item) {
+ return item.text;
+ },
+ clicked(item, $el, e) {
+ e.preventDefault();
+ onSelect();
+ }
+ });
+ }
+ }
+
+})(window);
diff --git a/app/assets/javascripts/protected_branch_create.js.es6 b/app/assets/javascripts/protected_branch_create.js.es6
new file mode 100644
index 00000000000..00e20a03b04
--- /dev/null
+++ b/app/assets/javascripts/protected_branch_create.js.es6
@@ -0,0 +1,56 @@
+(global => {
+ global.gl = global.gl || {};
+
+ gl.ProtectedBranchCreate = class {
+ constructor() {
+ this.$wrap = this.$form = $('#new_protected_branch');
+ this.buildDropdowns();
+ }
+
+ buildDropdowns() {
+ const $allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
+ const $allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
+
+ // Cache callback
+ this.onSelectCallback = this.onSelect.bind(this);
+
+ // Allowed to Merge dropdown
+ new gl.ProtectedBranchAccessDropdown({
+ $dropdown: $allowedToMergeDropdown,
+ data: gon.merge_access_levels,
+ onSelect: this.onSelectCallback
+ });
+
+ // Allowed to Push dropdown
+ new gl.ProtectedBranchAccessDropdown({
+ $dropdown: $allowedToPushDropdown,
+ data: gon.push_access_levels,
+ onSelect: this.onSelectCallback
+ });
+
+ // Select default
+ $allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0);
+ $allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
+
+ // Protected branch dropdown
+ new ProtectedBranchDropdown({
+ $dropdown: this.$wrap.find('.js-protected-branch-select'),
+ onSelect: this.onSelectCallback
+ });
+ }
+
+ // This will run after clicked callback
+ onSelect() {
+
+ // Enable submit button
+ const $branchInput = this.$wrap.find('input[name="protected_branch[name]"]');
+ const $allowedToMergeInput = this.$wrap.find('input[name="protected_branch[merge_access_level_attributes][access_level]"]');
+ const $allowedToPushInput = this.$wrap.find('input[name="protected_branch[push_access_level_attributes][access_level]"]');
+
+ if ($branchInput.val() && $allowedToMergeInput.val() && $allowedToPushInput.val()){
+ this.$form.find('input[type="submit"]').removeAttr('disabled');
+ }
+ }
+ }
+
+})(window);
diff --git a/app/assets/javascripts/protected_branch_dropdown.js.es6 b/app/assets/javascripts/protected_branch_dropdown.js.es6
new file mode 100644
index 00000000000..6738dc8862d
--- /dev/null
+++ b/app/assets/javascripts/protected_branch_dropdown.js.es6
@@ -0,0 +1,75 @@
+class ProtectedBranchDropdown {
+ constructor(options) {
+ this.onSelect = options.onSelect;
+ this.$dropdown = options.$dropdown;
+ this.$dropdownContainer = this.$dropdown.parent();
+ this.$dropdownFooter = this.$dropdownContainer.find('.dropdown-footer');
+ this.$protectedBranch = this.$dropdownContainer.find('.create-new-protected-branch');
+
+ this.buildDropdown();
+ this.bindEvents();
+
+ // Hide footer
+ this.$dropdownFooter.addClass('hidden');
+ }
+
+ buildDropdown() {
+ this.$dropdown.glDropdown({
+ data: this.getProtectedBranches.bind(this),
+ filterable: true,
+ remote: false,
+ search: {
+ fields: ['title']
+ },
+ selectable: true,
+ toggleLabel(selected) {
+ return (selected && 'id' in selected) ? selected.title : 'Protected Branch';
+ },
+ fieldName: 'protected_branch[name]',
+ text(protectedBranch) {
+ return _.escape(protectedBranch.title);
+ },
+ id(protectedBranch) {
+ return _.escape(protectedBranch.id);
+ },
+ onFilter: this.toggleCreateNewButton.bind(this),
+ clicked: (item, $el, e) => {
+ e.preventDefault();
+ this.onSelect();
+ }
+ });
+ }
+
+ bindEvents() {
+ this.$protectedBranch.on('click', this.onClickCreateWildcard.bind(this));
+ }
+
+ onClickCreateWildcard() {
+ this.$dropdown.data('glDropdown').remote.execute();
+ this.$dropdown.data('glDropdown').selectRowAtIndex(0);
+ }
+
+ getProtectedBranches(term, callback) {
+ if (this.selectedBranch) {
+ callback(gon.open_branches.concat(this.selectedBranch));
+ } else {
+ callback(gon.open_branches);
+ }
+ }
+
+ toggleCreateNewButton(branchName) {
+ this.selectedBranch = {
+ title: branchName,
+ id: branchName,
+ text: branchName
+ };
+
+ if (branchName) {
+ this.$dropdownContainer
+ .find('.create-new-protected-branch code')
+ .text(branchName);
+ }
+
+ this.$dropdownFooter.toggleClass('hidden', !branchName);
+ }
+}
diff --git a/app/assets/javascripts/protected_branch_edit.js.es6 b/app/assets/javascripts/protected_branch_edit.js.es6
new file mode 100644
index 00000000000..8d42e268ebc
--- /dev/null
+++ b/app/assets/javascripts/protected_branch_edit.js.es6
@@ -0,0 +1,61 @@
+(global => {
+ global.gl = global.gl || {};
+
+ gl.ProtectedBranchEdit = class {
+ constructor(options) {
+ this.$wrap = options.$wrap;
+ this.$allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
+ this.$allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
+
+ this.buildDropdowns();
+ }
+
+ buildDropdowns() {
+
+ // Allowed to merge dropdown
+ new gl.ProtectedBranchAccessDropdown({
+ $dropdown: this.$allowedToMergeDropdown,
+ data: gon.merge_access_levels,
+ onSelect: this.onSelect.bind(this)
+ });
+
+ // Allowed to push dropdown
+ new gl.ProtectedBranchAccessDropdown({
+ $dropdown: this.$allowedToPushDropdown,
+ data: gon.push_access_levels,
+ onSelect: this.onSelect.bind(this)
+ });
+ }
+
+ onSelect() {
+ const $allowedToMergeInput = this.$wrap.find(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`);
+ const $allowedToPushInput = this.$wrap.find(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`);
+
+ $.ajax({
+ type: 'POST',
+ url: this.$wrap.data('url'),
+ dataType: 'json',
+ data: {
+ _method: 'PATCH',
+ id: this.$wrap.data('banchId'),
+ protected_branch: {
+ merge_access_level_attributes: {
+ access_level: $allowedToMergeInput.val()
+ },
+ push_access_level_attributes: {
+ access_level: $allowedToPushInput.val()
+ }
+ }
+ },
+ success: () => {
+ this.$wrap.effect('highlight');
+ },
+ error() {
+ $.scrollTo(0);
+ new Flash('Failed to update branch!');
+ }
+ });
+ }
+ }
+
+})(window);
diff --git a/app/assets/javascripts/protected_branch_edit_list.js.es6 b/app/assets/javascripts/protected_branch_edit_list.js.es6
new file mode 100644
index 00000000000..9ff0fd12c76
--- /dev/null
+++ b/app/assets/javascripts/protected_branch_edit_list.js.es6
@@ -0,0 +1,17 @@
+(global => {
+ global.gl = global.gl || {};
+
+ gl.ProtectedBranchEditList = class {
+ constructor() {
+ this.$wrap = $('.protected-branches-list');
+
+ // Build edit forms
+ this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => {
+ new gl.ProtectedBranchEdit({
+ $wrap: $(el)
+ });
+ });
+ }
+ }
+
+})(window);
diff --git a/app/assets/javascripts/protected_branch_select.js b/app/assets/javascripts/protected_branch_select.js
deleted file mode 100644
index 3a47fc972dc..00000000000
--- a/app/assets/javascripts/protected_branch_select.js
+++ /dev/null
@@ -1,72 +0,0 @@
-(function() {
- var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
-
- this.ProtectedBranchSelect = (function() {
- function ProtectedBranchSelect(currentProject) {
- this.toggleCreateNewButton = bind(this.toggleCreateNewButton, this);
- this.getProtectedBranches = bind(this.getProtectedBranches, this);
- $('.dropdown-footer').hide();
- this.dropdown = $('.js-protected-branch-select').glDropdown({
- data: this.getProtectedBranches,
- filterable: true,
- remote: false,
- search: {
- fields: ['title']
- },
- selectable: true,
- toggleLabel: function(selected) {
- if (selected && 'id' in selected) {
- return selected.title;
- } else {
- return 'Protected Branch';
- }
- },
- fieldName: 'protected_branch[name]',
- text: function(protected_branch) {
- return _.escape(protected_branch.title);
- },
- id: function(protected_branch) {
- return _.escape(protected_branch.id);
- },
- onFilter: this.toggleCreateNewButton,
- clicked: function() {
- return $('.protect-branch-btn').attr('disabled', false);
- }
- });
- $('.create-new-protected-branch').on('click', (function(_this) {
- return function(event) {
- _this.dropdown.data('glDropdown').remote.execute();
- return _this.dropdown.data('glDropdown').selectRowAtIndex(event, 0);
- };
- })(this));
- }
-
- ProtectedBranchSelect.prototype.getProtectedBranches = function(term, callback) {
- if (this.selectedBranch) {
- return callback(gon.open_branches.concat(this.selectedBranch));
- } else {
- return callback(gon.open_branches);
- }
- };
-
- ProtectedBranchSelect.prototype.toggleCreateNewButton = function(branchName) {
- this.selectedBranch = {
- title: branchName,
- id: branchName,
- text: branchName
- };
- if (branchName === '') {
- $('.protected-branch-select-footer-list').addClass('hidden');
- return $('.dropdown-footer').hide();
- } else {
- $('.create-new-protected-branch').text("Create Protected Branch: " + branchName);
- $('.protected-branch-select-footer-list').removeClass('hidden');
- return $('.dropdown-footer').show();
- }
- };
-
- return ProtectedBranchSelect;
-
- })();
-
-}).call(this);
diff --git a/app/assets/javascripts/protected_branches_access_select.js.es6 b/app/assets/javascripts/protected_branches_access_select.js.es6
deleted file mode 100644
index e98312bbf37..00000000000
--- a/app/assets/javascripts/protected_branches_access_select.js.es6
+++ /dev/null
@@ -1,63 +0,0 @@
-class ProtectedBranchesAccessSelect {
- constructor(container, saveOnSelect, selectDefault) {
- this.container = container;
- this.saveOnSelect = saveOnSelect;
-
- this.container.find(".allowed-to-merge").each((i, element) => {
- var fieldName = $(element).data('field-name');
- var dropdown = $(element).glDropdown({
- data: gon.merge_access_levels,
- selectable: true,
- fieldName: fieldName,
- clicked: _.chain(this.onSelect).partial(element).bind(this).value()
- });
-
- if (selectDefault) {
- dropdown.data('glDropdown').selectRowAtIndex(document.createEvent("Event"), 0);
- }
- });
-
-
- this.container.find(".allowed-to-push").each((i, element) => {
- var fieldName = $(element).data('field-name');
- var dropdown = $(element).glDropdown({
- data: gon.push_access_levels,
- selectable: true,
- fieldName: fieldName,
- clicked: _.chain(this.onSelect).partial(element).bind(this).value()
- });
-
- if (selectDefault) {
- dropdown.data('glDropdown').selectRowAtIndex(document.createEvent("Event"), 0);
- }
- });
- }
-
- onSelect(dropdown, selected, element, e) {
- $(dropdown).find('.dropdown-toggle-text').text(selected.text);
- if (this.saveOnSelect) {
- return $.ajax({
- type: "POST",
- url: $(dropdown).data('url'),
- dataType: "json",
- data: {
- _method: 'PATCH',
- id: $(dropdown).data('id'),
- protected_branch: {
- ["" + ($(dropdown).data('type')) + "_attributes"]: {
- "access_level": selected.id
- }
- }
- },
- success: function() {
- var row;
- row = $(e.target);
- return row.closest('tr').effect('highlight');
- },
- error: function() {
- return new Flash("Failed to update branch!", "alert");
- }
- });
- }
- }
-}
diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js
index 4af2a214e12..65d362e072c 100644
--- a/app/assets/javascripts/users_select.js
+++ b/app/assets/javascripts/users_select.js
@@ -13,14 +13,15 @@
}
$('.js-user-search').each((function(_this) {
return function(i, dropdown) {
+ var options = {};
var $block, $collapsedSidebar, $dropdown, $loading, $selectbox, $value, abilityName, assignTo, assigneeTemplate, collapsedAssigneeTemplate, defaultLabel, firstUser, issueURL, selectedId, showAnyUser, showNullUser;
$dropdown = $(dropdown);
- _this.projectId = $dropdown.data('project-id');
- _this.showCurrentUser = $dropdown.data('current-user');
+ options.projectId = $dropdown.data('project-id');
+ options.showCurrentUser = $dropdown.data('current-user');
showNullUser = $dropdown.data('null-user');
showAnyUser = $dropdown.data('any-user');
firstUser = $dropdown.data('first-user');
- _this.authorId = $dropdown.data('author-id');
+ options.authorId = $dropdown.data('author-id');
selectedId = $dropdown.data('selected');
defaultLabel = $dropdown.data('default-label');
issueURL = $dropdown.data('issueUpdate');
@@ -75,7 +76,7 @@
data: function(term, callback) {
var isAuthorFilter;
isAuthorFilter = $('.js-author-search');
- return _this.users(term, function(users) {
+ return _this.users(term, options, function(users) {
var anyUser, index, j, len, name, obj, showDivider;
if (term.length === 0) {
showDivider = 0;
@@ -185,11 +186,14 @@
$('.ajax-users-select').each((function(_this) {
return function(i, select) {
var firstUser, showAnyUser, showEmailUser, showNullUser;
- _this.projectId = $(select).data('project-id');
- _this.groupId = $(select).data('group-id');
- _this.showCurrentUser = $(select).data('current-user');
- _this.authorId = $(select).data('author-id');
- _this.skipUsers = $(select).data('skip-users');
+ var options = {};
+ options.skipLdap = $(select).hasClass('skip_ldap');
+ options.projectId = $(select).data('project-id');
+ options.groupId = $(select).data('group-id');
+ options.showCurrentUser = $(select).data('current-user');
+ options.pushCodeToProtectedBranches = $(select).data('push-code-to-protected-branches');
+ options.authorId = $(select).data('author-id');
+ options.skipUsers = $(select).data('skip-users');
showNullUser = $(select).data('null-user');
showAnyUser = $(select).data('any-user');
showEmailUser = $(select).data('email-user');
@@ -199,7 +203,7 @@
multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0,
query: function(query) {
- return _this.users(query.term, function(users) {
+ return _this.users(query.term, options, function(users) {
var anyUser, data, emailUser, index, j, len, name, nullUser, obj, ref;
data = {
results: users
@@ -309,7 +313,7 @@
});
};
- UsersSelect.prototype.users = function(query, callback) {
+ UsersSelect.prototype.users = function(query, options, callback) {
var url;
url = this.buildUrl(this.usersPath);
return $.ajax({
@@ -318,11 +322,13 @@
search: query,
per_page: 20,
active: true,
- project_id: this.projectId,
- group_id: this.groupId,
- current_user: this.showCurrentUser,
- author_id: this.authorId,
- skip_users: this.skipUsers
+ project_id: options.projectId || null,
+ group_id: options.groupId || null,
+ skip_ldap: options.skipLdap || null,
+ current_user: options.showCurrentUser || null,
+ push_code_to_protected_branches: options.pushCodeToProtectedBranches || null,
+ author_id: options.authorId || null,
+ skip_users: options.skipUsers || null
},
dataType: "json"
}).done(function(users) {
diff --git a/app/assets/stylesheets/framework/dropdowns.scss b/app/assets/stylesheets/framework/dropdowns.scss
index c54eb0d6479..e8eafa15899 100644
--- a/app/assets/stylesheets/framework/dropdowns.scss
+++ b/app/assets/stylesheets/framework/dropdowns.scss
@@ -72,6 +72,14 @@
&.large {
width: 200px;
}
+
+ &.wide {
+ width: 100%;
+
+ + .dropdown-select {
+ width: 100%;
+ }
+ }
}
.dropdown-menu,
diff --git a/app/assets/stylesheets/framework/lists.scss b/app/assets/stylesheets/framework/lists.scss
index 2c40ec430ca..965fcc06518 100644
--- a/app/assets/stylesheets/framework/lists.scss
+++ b/app/assets/stylesheets/framework/lists.scss
@@ -114,6 +114,12 @@ ul.content-list {
font-size: $list-font-size;
color: $list-text-color;
+ &.no-description {
+ .title {
+ line-height: $list-text-height;
+ }
+ }
+
.title {
font-weight: 600;
}
@@ -134,12 +140,11 @@ ul.content-list {
}
.controls {
- padding-top: 1px;
float: right;
> .control-text {
margin-right: $gl-padding-top;
- line-height: 40px;
+ line-height: $list-text-height;
&:last-child {
margin-right: 0;
@@ -150,7 +155,7 @@ ul.content-list {
> .btn-group {
margin-right: $gl-padding-top;
display: inline-block;
- margin-top: 4px;
+ margin-top: 3px;
margin-bottom: 4px;
&:last-child {
diff --git a/app/assets/stylesheets/framework/panels.scss b/app/assets/stylesheets/framework/panels.scss
index 874416e1007..c6f30e144fd 100644
--- a/app/assets/stylesheets/framework/panels.scss
+++ b/app/assets/stylesheets/framework/panels.scss
@@ -23,4 +23,9 @@
margin-top: $gl-padding;
}
}
+
+ .panel-title {
+ font-size: inherit;
+ line-height: inherit;
+ }
}
diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss
index 1882d4e888d..ca720022539 100644
--- a/app/assets/stylesheets/framework/variables.scss
+++ b/app/assets/stylesheets/framework/variables.scss
@@ -43,6 +43,7 @@ $gl-header-color: $gl-title-color;
$list-font-size: $gl-font-size;
$list-title-color: $gl-title-color;
$list-text-color: $gl-text-color;
+$list-text-height: 42px;
/*
* Markdown
diff --git a/app/assets/stylesheets/pages/groups.scss b/app/assets/stylesheets/pages/groups.scss
index 2a3acc3eb4c..b657ca47d38 100644
--- a/app/assets/stylesheets/pages/groups.scss
+++ b/app/assets/stylesheets/pages/groups.scss
@@ -23,15 +23,9 @@
}
.group-row {
- &.no-description {
- .group-name {
- line-height: 44px;
- }
- }
-
.stats {
float: right;
- line-height: 44px;
+ line-height: $list-text-height;
color: $gl-gray;
span {
diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss
index 4409477916f..cf9aa02600d 100644
--- a/app/assets/stylesheets/pages/projects.scss
+++ b/app/assets/stylesheets/pages/projects.scss
@@ -512,18 +512,12 @@ pre.light-well {
.project-row {
border-color: $table-border-color;
- &.no-description {
- .project {
- line-height: 40px;
- }
- }
-
.project-full-name {
@include str-truncated;
}
.controls {
- line-height: 40px;
+ line-height: $list-text-height;
a:hover {
text-decoration: none;
@@ -662,13 +656,9 @@ pre.light-well {
}
.new_protected_branch {
- .dropdown {
- display: inline;
- margin-left: 15px;
- }
-
label {
- min-width: 120px;
+ margin-top: 6px;
+ font-weight: normal;
}
}
@@ -684,6 +674,21 @@ pre.light-well {
font-weight: 600;
}
}
+
+ .settings-message {
+ margin: 0;
+ border-radius: 0 0 1px 1px;
+ padding: 20px 0;
+ border: none;
+ }
+
+ .table-bordered {
+ border-radius: 1px;
+
+ th:not(:last-child), td:not(:last-child) {
+ border-right: solid 1px transparent;
+ }
+ }
}
.custom-notifications-form {
diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb
index c780e0983f9..6217ec5ecef 100644
--- a/app/controllers/profiles/passwords_controller.rb
+++ b/app/controllers/profiles/passwords_controller.rb
@@ -50,6 +50,7 @@ class Profiles::PasswordsController < Profiles::ApplicationController
flash[:notice] = "Password was successfully updated. Please login with it"
redirect_to new_user_session_path
else
+ @user.reload
render 'edit'
end
end
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index eda3727a28d..19d051720e9 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -76,6 +76,8 @@ class Projects::BlobController < Projects::ApplicationController
end
def diff
+ apply_diff_view_cookie!
+
@form = UnfoldForm.new(params)
@lines = Gitlab::Highlight.highlight_lines(repository, @ref, @path)
@lines = @lines[@form.since - 1..@form.to - 1]
diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb
index 83d5ced9be8..529e0aa2d33 100644
--- a/app/controllers/projects/deploy_keys_controller.rb
+++ b/app/controllers/projects/deploy_keys_controller.rb
@@ -12,8 +12,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
def new
- redirect_to namespace_project_deploy_keys_path(@project.namespace,
- @project)
+ redirect_to namespace_project_deploy_keys_path(@project.namespace, @project)
end
def create
@@ -21,19 +20,16 @@ class Projects::DeployKeysController < Projects::ApplicationController
set_index_vars
if @key.valid? && @project.deploy_keys << @key
- redirect_to namespace_project_deploy_keys_path(@project.namespace,
- @project)
+ redirect_to namespace_project_deploy_keys_path(@project.namespace, @project)
else
render "index"
end
end
def enable
- @key = accessible_keys.find(params[:id])
- @project.deploy_keys << @key
+ Projects::EnableDeployKeyService.new(@project, current_user, params).execute
- redirect_to namespace_project_deploy_keys_path(@project.namespace,
- @project)
+ redirect_to namespace_project_deploy_keys_path(@project.namespace, @project)
end
def disable
@@ -45,9 +41,9 @@ class Projects::DeployKeysController < Projects::ApplicationController
protected
def set_index_vars
- @enabled_keys ||= @project.deploy_keys
+ @enabled_keys ||= @project.deploy_keys
- @available_keys ||= accessible_keys - @enabled_keys
+ @available_keys ||= current_user.accessible_deploy_keys - @enabled_keys
@available_project_keys ||= current_user.project_deploy_keys - @enabled_keys
@available_public_keys ||= DeployKey.are_public - @enabled_keys
@@ -56,10 +52,6 @@ class Projects::DeployKeysController < Projects::ApplicationController
@available_public_keys -= @available_project_keys
end
- def accessible_keys
- @accessible_keys ||= current_user.accessible_deploy_keys
- end
-
def deploy_key_params
params.require(:deploy_key).permit(:key, :title)
end
diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb
index 40a8b7940d9..e2f93e239bd 100644
--- a/app/controllers/projects/git_http_controller.rb
+++ b/app/controllers/projects/git_http_controller.rb
@@ -20,9 +20,9 @@ class Projects::GitHttpController < Projects::ApplicationController
elsif receive_pack? && receive_pack_allowed?
render_ok
elsif http_blocked?
- render_not_allowed
+ render_http_not_allowed
else
- render_not_found
+ render_denied
end
end
@@ -31,7 +31,7 @@ class Projects::GitHttpController < Projects::ApplicationController
if upload_pack? && upload_pack_allowed?
render_ok
else
- render_not_found
+ render_denied
end
end
@@ -40,7 +40,7 @@ class Projects::GitHttpController < Projects::ApplicationController
if receive_pack? && receive_pack_allowed?
render_ok
else
- render_not_found
+ render_denied
end
end
@@ -156,8 +156,17 @@ class Projects::GitHttpController < Projects::ApplicationController
render plain: 'Not Found', status: :not_found
end
- def render_not_allowed
- render plain: download_access.message, status: :forbidden
+ def render_http_not_allowed
+ render plain: access_check.message, status: :forbidden
+ end
+
+ def render_denied
+ if user && user.can?(:read_project, project)
+ render plain: 'Access denied', status: :forbidden
+ else
+ # Do not leak information about project existence
+ render_not_found
+ end
end
def ci?
@@ -168,22 +177,20 @@ class Projects::GitHttpController < Projects::ApplicationController
return false unless Gitlab.config.gitlab_shell.upload_pack
if user
- download_access.allowed?
+ access_check.allowed?
else
ci? || project.public?
end
end
def access
- return @access if defined?(@access)
-
- @access = Gitlab::GitAccess.new(user, project, 'http')
+ @access ||= Gitlab::GitAccess.new(user, project, 'http')
end
- def download_access
- return @download_access if defined?(@download_access)
-
- @download_access = access.check('git-upload-pack')
+ def access_check
+ # Use the magic string '_any' to indicate we do not know what the
+ # changes are. This is also what gitlab-shell does.
+ @access_check ||= access.check(git_command, '_any')
end
def http_blocked?
@@ -193,8 +200,6 @@ class Projects::GitHttpController < Projects::ApplicationController
def receive_pack_allowed?
return false unless Gitlab.config.gitlab_shell.receive_pack
- # Skip user authorization on upload request.
- # It will be done by the pre-receive hook in the repository.
- user.present?
+ access_check.allowed?
end
end
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index 75b78a49eab..3327f4f2b87 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -33,7 +33,7 @@ class RegistrationsController < Devise::RegistrationsController
protected
- def build_resource(hash=nil)
+ def build_resource(hash = nil)
super
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 50de93d4bdf..c3613bc67dd 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -163,9 +163,13 @@ module ApplicationHelper
# `html_class` argument is provided.
#
# Returns an HTML-safe String
- def time_ago_with_tooltip(time, placement: 'top', html_class: 'time_ago', skip_js: false)
+ def time_ago_with_tooltip(time, placement: 'top', html_class: '', skip_js: false, short_format: false)
+ css_classes = short_format ? 'js-short-timeago' : 'js-timeago'
+ css_classes << " #{html_class}" unless html_class.blank?
+ css_classes << ' js-timeago-pending' unless skip_js
+
element = content_tag :time, time.to_s,
- class: "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}",
+ class: css_classes,
datetime: time.to_time.getutc.iso8601,
title: time.to_time.in_time_zone.to_s(:medium),
data: { toggle: 'tooltip', placement: placement, container: 'body' }
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb
index 6ff40c6b461..2160cf7a690 100644
--- a/app/helpers/avatars_helper.rb
+++ b/app/helpers/avatars_helper.rb
@@ -1,5 +1,4 @@
module AvatarsHelper
-
def author_avatar(commit_or_event, options = {})
user_avatar(options.merge({
user: commit_or_event.author,
@@ -26,5 +25,4 @@ module AvatarsHelper
mail_to(options[:user_email], avatar)
end
end
-
end
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index cc7121b1163..f3c9ea074b4 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -13,12 +13,11 @@ module DiffHelper
end
def diff_view
- diff_views = %w(inline parallel)
-
- if diff_views.include?(cookies[:diff_view])
- cookies[:diff_view]
- else
- diff_views.first
+ @diff_view ||= begin
+ diff_views = %w(inline parallel)
+ diff_view = cookies[:diff_view]
+ diff_view = diff_views.first unless diff_views.include?(diff_view)
+ diff_view.to_sym
end
end
@@ -33,12 +32,23 @@ module DiffHelper
options
end
- def unfold_bottom_class(bottom)
- bottom ? 'js-unfold js-unfold-bottom' : ''
- end
+ def diff_match_line(old_pos, new_pos, text: '', view: :inline, bottom: false)
+ content = content_tag :td, text, class: "line_content match #{view == :inline ? '' : view}"
+ cls = ['diff-line-num', 'unfold', 'js-unfold']
+ cls << 'js-unfold-bottom' if bottom
+
+ html = ''
+ if old_pos
+ html << content_tag(:td, '...', class: cls + ['old_line'], data: { linenumber: old_pos })
+ html << content unless view == :inline
+ end
+
+ if new_pos
+ html << content_tag(:td, '...', class: cls + ['new_line'], data: { linenumber: new_pos })
+ html << content
+ end
- def unfold_class(unfold)
- unfold ? 'unfold js-unfold' : ''
+ html.html_safe
end
def diff_line_content(line, line_type = nil)
@@ -67,11 +77,11 @@ module DiffHelper
end
def inline_diff_btn
- diff_btn('Inline', 'inline', diff_view == 'inline')
+ diff_btn('Inline', 'inline', diff_view == :inline)
end
def parallel_diff_btn
- diff_btn('Side-by-side', 'parallel', diff_view == 'parallel')
+ diff_btn('Side-by-side', 'parallel', diff_view == :parallel)
end
def submodule_link(blob, ref, repository = @repository)
@@ -103,7 +113,8 @@ module DiffHelper
commit = commit_for_diff(diff_file)
{
blob_diff_path: namespace_project_blob_diff_path(project.namespace, project,
- tree_join(commit.id, diff_file.file_path))
+ tree_join(commit.id, diff_file.file_path)),
+ view: diff_view
}
end
diff --git a/app/helpers/explore_helper.rb b/app/helpers/explore_helper.rb
index 337b0aacbb5..2b1f3825adc 100644
--- a/app/helpers/explore_helper.rb
+++ b/app/helpers/explore_helper.rb
@@ -1,5 +1,5 @@
module ExploreHelper
- def filter_projects_path(options={})
+ def filter_projects_path(options = {})
exist_opts = {
sort: params[:sort],
scope: params[:scope],
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index a2bba139c17..c0195713f4a 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -107,7 +107,7 @@ module SearchHelper
Sanitize.clean(str)
end
- def search_filter_path(options={})
+ def search_filter_path(options = {})
exist_opts = {
search: params[:search],
project_id: params[:project_id],
diff --git a/app/models/ability.rb b/app/models/ability.rb
index d95a2507199..d9113ffd99a 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -6,6 +6,10 @@ class Ability
return [] unless user.is_a?(User)
return [] if user.blocked?
+ abilities_by_subject_class(user: user, subject: subject)
+ end
+
+ def abilities_by_subject_class(user:, subject:)
case subject
when CommitStatus then commit_status_abilities(user, subject)
when Project then project_abilities(user, subject)
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 6458d620459..5c85578bdf3 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -216,6 +216,8 @@ module Ci
Gitlab::DataBuilder::PipelineDataBuilder.build(self)
end
+ private
+
def keep_around_commits
return unless project
diff --git a/app/models/concerns/faster_cache_keys.rb b/app/models/concerns/faster_cache_keys.rb
new file mode 100644
index 00000000000..5b14723fa2d
--- /dev/null
+++ b/app/models/concerns/faster_cache_keys.rb
@@ -0,0 +1,16 @@
+module FasterCacheKeys
+ # A faster version of Rails' "cache_key" method.
+ #
+ # Rails' default "cache_key" method uses all kind of complex logic to figure
+ # out the cache key. In many cases this complexity and overhead may not be
+ # needed.
+ #
+ # This method does not do any timestamp parsing as this process is quite
+ # expensive and not needed when generating cache keys. This method also relies
+ # on the table name instead of the cache namespace name as the latter uses
+ # complex logic to generate the exact same value (as when using the table
+ # name) in 99% of the cases.
+ def cache_key
+ "#{self.class.table_name}/#{id}-#{read_attribute_before_type_cast(:updated_at)}"
+ end
+end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 11f734cfc6d..d62ffb21467 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -7,6 +7,7 @@ class Issue < ActiveRecord::Base
include Sortable
include Taskable
include Spammable
+ include FasterCacheKeys
DueDateStruct = Struct.new(:title, :name).freeze
NoDueDate = DueDateStruct.new('No Due Date', '0').freeze
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb
index f39afc61ce9..f176feddbad 100644
--- a/app/models/members/project_member.rb
+++ b/app/models/members/project_member.rb
@@ -21,19 +21,19 @@ class ProjectMember < Member
# or symbol like :master representing role
#
# Ex.
- # add_users_into_projects(
+ # add_users_to_projects(
# project_ids,
# user_ids,
# ProjectMember::MASTER
# )
#
- # add_users_into_projects(
+ # add_users_to_projects(
# project_ids,
# user_ids,
# :master
# )
#
- def add_users_into_projects(project_ids, user_ids, access, current_user = nil)
+ def add_users_to_projects(project_ids, user_ids, access, current_user = nil)
access_level = if roles_hash.has_key?(access)
roles_hash[access]
elsif roles_hash.values.include?(access.to_i)
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index fa0efe2d596..32cc6a3bfea 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -36,7 +36,7 @@ class MergeRequestDiff < ActiveRecord::Base
real_size.presence || raw_diffs.size
end
- def raw_diffs(options={})
+ def raw_diffs(options = {})
if options[:ignore_whitespace_change]
@raw_diffs_no_whitespace ||= begin
compare = Gitlab::Git::Compare.new(
diff --git a/app/models/note.rb b/app/models/note.rb
index b6b2ac6aa42..ddcd7f9d034 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -5,6 +5,7 @@ class Note < ActiveRecord::Base
include Mentionable
include Awardable
include Importable
+ include FasterCacheKeys
# Attribute containing rendered and redacted Markdown as generated by
# Banzai::ObjectRenderer.
diff --git a/app/models/project.rb b/app/models/project.rb
index a18aef09acd..a667857d058 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -865,10 +865,16 @@ class Project < ActiveRecord::Base
# Check if current branch name is marked as protected in the system
def protected_branch?(branch_name)
+ return true if empty_repo? && default_branch_protected?
+
@protected_branches ||= self.protected_branches.to_a
ProtectedBranch.matching(branch_name, protected_branches: @protected_branches).present?
end
+ def user_can_push_to_empty_repo?(user)
+ !default_branch_protected? || team.max_member_access(user.id) > Gitlab::Access::DEVELOPER
+ end
+
def forked?
!(forked_project_link.nil? || forked_project_link.forked_from_project.nil?)
end
@@ -1260,6 +1266,11 @@ class Project < ActiveRecord::Base
private
+ def default_branch_protected?
+ current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_FULL ||
+ current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE
+ end
+
def authorized_for_user_by_group?(user, min_access_level)
member = user.group_members.find_by(source_id: group)
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index 19fd082534c..d0a714cd6fc 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -34,7 +34,7 @@ class ProjectTeam
end
def add_users(users, access, current_user = nil)
- ProjectMember.add_users_into_projects(
+ ProjectMember.add_users_to_projects(
[project.id],
users,
access,
diff --git a/app/models/repository.rb b/app/models/repository.rb
index c1170c470ea..e56bac509a4 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -601,7 +601,7 @@ class Repository
commit(sha)
end
- def next_branch(name, opts={})
+ def next_branch(name, opts = {})
branch_ids = self.branch_names.map do |n|
next 1 if n == name
result = n.match(/\A#{name}-([0-9]+)\z/)
@@ -636,9 +636,7 @@ class Repository
def tags_sorted_by(value)
case value
when 'name'
- # Would be better to use `sort_by` but `version_sorter` only exposes
- # `sort` and `rsort`
- VersionSorter.rsort(tag_names).map { |tag_name| find_tag(tag_name) }
+ VersionSorter.rsort(tags) { |tag| tag.name }
when 'updated_desc'
tags_sorted_by_committed_date.reverse
when 'updated_asc'
diff --git a/app/services/projects/enable_deploy_key_service.rb b/app/services/projects/enable_deploy_key_service.rb
new file mode 100644
index 00000000000..3cf4264ce9b
--- /dev/null
+++ b/app/services/projects/enable_deploy_key_service.rb
@@ -0,0 +1,17 @@
+module Projects
+ class EnableDeployKeyService < BaseService
+ def execute
+ key = accessible_keys.find_by(id: params[:key_id] || params[:id])
+ return unless key
+
+ project.deploy_keys << key
+ key
+ end
+
+ private
+
+ def accessible_keys
+ current_user.accessible_deploy_keys
+ end
+ end
+end
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
index 23b52d08df7..c7fd344eea2 100644
--- a/app/views/admin/application_settings/_form.html.haml
+++ b/app/views/admin/application_settings/_form.html.haml
@@ -228,6 +228,9 @@
= f.label :max_artifacts_size, 'Maximum artifacts size (MB)', class: 'control-label col-sm-2'
.col-sm-10
= f.number_field :max_artifacts_size, class: 'form-control'
+ .help-block
+ Set the maximum file size each build's artifacts can have
+ = link_to "(?)", help_page_path("user/admin_area/settings/continuous_integration", anchor: "maximum-artifacts-size")
- if Gitlab.config.registry.enabled
%fieldset
@@ -363,7 +366,9 @@
.col-sm-10
= f.select :repository_storage, repository_storage_options_for_select, {}, class: 'form-control'
.help-block
- You can manage the repository storage paths in your gitlab.yml configuration file
+ Manage repository storage paths. Learn more in the
+ = succeed "." do
+ = link_to "repository storages documentation", help_page_path("administration/repository_storages")
%fieldset
%legend Repository Checks
@@ -385,4 +390,4 @@
.form-actions
- = f.submit 'Save', class: 'btn btn-save' \ No newline at end of file
+ = f.submit 'Save', class: 'btn btn-save'
diff --git a/app/views/notify/new_issue_email.text.erb b/app/views/notify/new_issue_email.text.erb
index fc64c98038b..ca5c2f2688c 100644
--- a/app/views/notify/new_issue_email.text.erb
+++ b/app/views/notify/new_issue_email.text.erb
@@ -3,3 +3,5 @@ New Issue was created.
Issue <%= @issue.iid %>: <%= url_for(namespace_project_issue_url(@issue.project.namespace, @issue.project, @issue)) %>
Author: <%= @issue.author_name %>
Assignee: <%= @issue.assignee_name %>
+
+<%= @issue.description %>
diff --git a/app/views/notify/new_merge_request_email.text.erb b/app/views/notify/new_merge_request_email.text.erb
index d4aad8d1862..3c8f178ac77 100644
--- a/app/views/notify/new_merge_request_email.text.erb
+++ b/app/views/notify/new_merge_request_email.text.erb
@@ -6,3 +6,5 @@ New Merge Request <%= @merge_request.to_reference %>
Author: <%= @merge_request.author_name %>
Assignee: <%= @merge_request.assignee_name %>
+<%= @merge_request.description %>
+
diff --git a/app/views/projects/blob/diff.html.haml b/app/views/projects/blob/diff.html.haml
index 5926d181ba3..a79ae53c780 100644
--- a/app/views/projects/blob/diff.html.haml
+++ b/app/views/projects/blob/diff.html.haml
@@ -1,20 +1,30 @@
- if @lines.present?
+ - line_class = diff_view == :inline ? '' : diff_view
- if @form.unfold? && @form.since != 1 && !@form.bottom?
- %tr.line_holder
- = render "projects/diffs/match_line", { line: @match_line,
- line_old: @form.since, line_new: @form.since, bottom: false, new_file: false }
+ %tr.line_holder{ class: line_class }
+ = diff_match_line @form.since, @form.since, text: @match_line, view: diff_view
- @lines.each_with_index do |line, index|
- line_new = index + @form.since
- line_old = line_new - @form.offset
- %tr.line_holder{ id: line_old }
- %td.old_line.diff-line-num{ data: { linenumber: line_old } }
- = link_to raw(line_old), "##{line_old}"
- %td.new_line.diff-line-num{ data: { linenumber: line_old } }
- = link_to raw(line_new) , "##{line_old}"
- %td.line_content.noteable_line==#{' ' * @form.indent}#{line}
+ - line_content = capture do
+ %td.line_content.noteable_line{ class: line_class }==#{' ' * @form.indent}#{line}
+ %tr.line_holder{ id: line_old, class: line_class }
+ - case diff_view
+ - when :inline
+ %td.old_line.diff-line-num{ data: { linenumber: line_old } }
+ %a{href: "##{line_old}", data: { linenumber: line_old }}
+ %td.new_line.diff-line-num{ data: { linenumber: line_new } }
+ %a{href: "##{line_new}", data: { linenumber: line_new }}
+ = line_content
+ - when :parallel
+ %td.old_line.diff-line-num{data: { linenumber: line_old }}
+ = link_to raw(line_old), "##{line_old}"
+ = line_content
+ %td.new_line.diff-line-num{data: { linenumber: line_new }}
+ = link_to raw(line_new), "##{line_new}"
+ = line_content
- if @form.unfold? && @form.bottom? && @form.to < @blob.loc
- %tr.line_holder{ id: @form.to }
- = render "projects/diffs/match_line", { line: @match_line,
- line_old: @form.to, line_new: @form.to, bottom: true, new_file: false }
+ %tr.line_holder{ id: @form.to, class: line_class }
+ = diff_match_line @form.to, @form.to, text: @match_line, view: diff_view, bottom: true
diff --git a/app/views/projects/ci/pipelines/_pipeline.html.haml b/app/views/projects/ci/pipelines/_pipeline.html.haml
index c8003ecef2e..78709a92aed 100644
--- a/app/views/projects/ci/pipelines/_pipeline.html.haml
+++ b/app/views/projects/ci/pipelines/_pipeline.html.haml
@@ -53,7 +53,7 @@
- if pipeline.finished_at
%p.finished-at
= icon("calendar")
- #{time_ago_with_tooltip(pipeline.finished_at)}
+ #{time_ago_with_tooltip(pipeline.finished_at, short_format: true, skip_js: true)}
%td.pipeline-actions
.controls.hidden-xs.pull-right
diff --git a/app/views/projects/diffs/_content.html.haml b/app/views/projects/diffs/_content.html.haml
index a1b071f130c..d37961c4e40 100644
--- a/app/views/projects/diffs/_content.html.haml
+++ b/app/views/projects/diffs/_content.html.haml
@@ -13,7 +13,7 @@
.nothing-here-block.diff-collapsed{data: { diff_for_path: url } }
This diff is collapsed. Click to expand it.
- elsif diff_file.diff_lines.length > 0
- - if diff_view == 'parallel'
+ - if diff_view == :parallel
= render "projects/diffs/parallel_view", diff_file: diff_file, project: project, blob: blob
- else
= render "projects/diffs/text_file", diff_file: diff_file
diff --git a/app/views/projects/diffs/_diffs.html.haml b/app/views/projects/diffs/_diffs.html.haml
index ebaf939f930..62aff36aadd 100644
--- a/app/views/projects/diffs/_diffs.html.haml
+++ b/app/views/projects/diffs/_diffs.html.haml
@@ -1,6 +1,6 @@
- show_whitespace_toggle = local_assigns.fetch(:show_whitespace_toggle, true)
- diff_files = diffs.diff_files
-- if diff_view == 'parallel'
+- if diff_view == :parallel
- fluid_layout true
.content-block.oneline-block.files-changed
diff --git a/app/views/projects/diffs/_line.html.haml b/app/views/projects/diffs/_line.html.haml
index 4d3af905b58..2d6a370b848 100644
--- a/app/views/projects/diffs/_line.html.haml
+++ b/app/views/projects/diffs/_line.html.haml
@@ -4,8 +4,7 @@
%tr.line_holder{ plain ? { class: type} : { class: type, id: line_code } }
- case type
- when 'match'
- = render "projects/diffs/match_line", { line: line.text,
- line_old: line.old_pos, line_new: line.new_pos, bottom: false, new_file: diff_file.new_file }
+ = diff_match_line line.old_pos, line.new_pos, text: line.text
- when 'nonewline'
%td.old_line.diff-line-num
%td.new_line.diff-line-num
diff --git a/app/views/projects/diffs/_match_line.html.haml b/app/views/projects/diffs/_match_line.html.haml
deleted file mode 100644
index d6dddd97879..00000000000
--- a/app/views/projects/diffs/_match_line.html.haml
+++ /dev/null
@@ -1,7 +0,0 @@
-%td.old_line.diff-line-num{data: {linenumber: line_old},
- class: [unfold_bottom_class(bottom), unfold_class(!new_file)]}
- \...
-%td.new_line.diff-line-num{data: {linenumber: line_new},
- class: [unfold_bottom_class(bottom), unfold_class(!new_file)]}
- \...
-%td.line_content.match= line
diff --git a/app/views/projects/diffs/_parallel_view.html.haml b/app/views/projects/diffs/_parallel_view.html.haml
index 7f30faa20d8..28aad3f4725 100644
--- a/app/views/projects/diffs/_parallel_view.html.haml
+++ b/app/views/projects/diffs/_parallel_view.html.haml
@@ -1,14 +1,15 @@
/ Side-by-side diff view
%div.text-file.diff-wrap-lines.code.file-content.js-syntax-highlight{ data: diff_view_data }
%table
+ - last_line = 0
- diff_file.parallel_diff_lines.each do |line|
- left = line[:left]
- right = line[:right]
+ - last_line = right.new_pos if right
%tr.line_holder.parallel
- if left
- if left.meta?
- %td.old_line.diff-line-num.empty-cell
- %td.line_content.parallel.match= left.text
+ = diff_match_line left.old_pos, nil, text: left.text, view: :parallel
- else
- left_line_code = diff_file.line_code(left)
- left_position = diff_file.position(left)
@@ -21,8 +22,7 @@
- if right
- if right.meta?
- %td.old_line.diff-line-num.empty-cell
- %td.line_content.parallel.match= left.text
+ = diff_match_line nil, right.new_pos, text: left.text, view: :parallel
- else
- right_line_code = diff_file.line_code(right)
- right_position = diff_file.position(right)
@@ -37,3 +37,5 @@
- discussion_left, discussion_right = parallel_diff_discussions(left, right, diff_file)
- if discussion_left || discussion_right
= render "discussions/parallel_diff_discussion", discussion_left: discussion_left, discussion_right: discussion_right
+ - if !diff_file.new_file && last_line > 0
+ = diff_match_line last_line, last_line, bottom: true, view: :parallel
diff --git a/app/views/projects/diffs/_text_file.html.haml b/app/views/projects/diffs/_text_file.html.haml
index 5970b9abf2b..ab5463ba89d 100644
--- a/app/views/projects/diffs/_text_file.html.haml
+++ b/app/views/projects/diffs/_text_file.html.haml
@@ -15,6 +15,5 @@
- if discussion
= render "discussions/diff_discussion", discussion: discussion
- - if last_line > 0
- = render "projects/diffs/match_line", { line: "",
- line_old: last_line, line_new: last_line, bottom: true, new_file: diff_file.new_file }
+ - if !diff_file.new_file && last_line > 0
+ = diff_match_line last_line, last_line, bottom: true
diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml
index 873ed9b59ee..269198adf91 100644
--- a/app/views/projects/merge_requests/_show.html.haml
+++ b/app/views/projects/merge_requests/_show.html.haml
@@ -2,7 +2,7 @@
- page_description @merge_request.description
- page_card_attributes @merge_request.card_attributes
-- if diff_view == 'parallel'
+- if diff_view == :parallel
- fluid_layout true
.merge-request{'data-url' => merge_request_path(@merge_request)}
diff --git a/app/views/projects/protected_branches/_branches_list.html.haml b/app/views/projects/protected_branches/_branches_list.html.haml
index 0603a014008..04b19a8c5a7 100644
--- a/app/views/projects/protected_branches/_branches_list.html.haml
+++ b/app/views/projects/protected_branches/_branches_list.html.haml
@@ -1,26 +1,28 @@
-%h5.prepend-top-0
- Already Protected (#{@protected_branches.size})
-- if @protected_branches.empty?
- %p.settings-message.text-center
- No branches are protected, protect a branch with the form above.
-- else
- - can_admin_project = can?(current_user, :admin_project, @project)
+.panel.panel-default.protected-branches-list
+ - if @protected_branches.empty?
+ .panel-heading
+ %h3.panel-title
+ Protected branch (#{@protected_branches.size})
+ %p.settings-message.text-center
+ There are currently no protected branches, protect a branch with the form above.
+ - else
+ - can_admin_project = can?(current_user, :admin_project, @project)
- %table.table.protected-branches-list
- %colgroup
- %col{ width: "20%" }
- %col{ width: "30%" }
- %col{ width: "25%" }
- %col{ width: "25%" }
- %thead
- %tr
- %th Branch
- %th Last commit
- %th Allowed to merge
- %th Allowed to push
- - if can_admin_project
- %th
- %tbody
- = render partial: @protected_branches, locals: { can_admin_project: can_admin_project }
+ %table.table.table-bordered
+ %colgroup
+ %col{ width: "25%" }
+ %col{ width: "30%" }
+ %col{ width: "25%" }
+ %col{ width: "20%" }
+ %thead
+ %tr
+ %th Protected branch (#{@protected_branches.size})
+ %th Last commit
+ %th Allowed to merge
+ %th Allowed to push
+ - if can_admin_project
+ %th
+ %tbody
+ = render partial: @protected_branches, locals: { can_admin_project: can_admin_project }
- = paginate @protected_branches, theme: 'gitlab'
+ = paginate @protected_branches, theme: 'gitlab'
diff --git a/app/views/projects/protected_branches/_create_protected_branch.html.haml b/app/views/projects/protected_branches/_create_protected_branch.html.haml
new file mode 100644
index 00000000000..85d0c494ba8
--- /dev/null
+++ b/app/views/projects/protected_branches/_create_protected_branch.html.haml
@@ -0,0 +1,36 @@
+= form_for [@project.namespace.becomes(Namespace), @project, @protected_branch] do |f|
+ .panel.panel-default
+ .panel-heading
+ %h3.panel-title
+ Protect a branch
+ .panel-body
+ .form-horizontal
+ .form-group
+ = f.label :name, class: 'col-md-2 text-right' do
+ Branch:
+ .col-md-10
+ = render partial: "dropdown", locals: { f: f }
+ .help-block
+ = link_to 'Wildcards', help_page_path('user/project/protected_branches', anchor: 'wildcard-protected-branches')
+ such as
+ %code *-stable
+ or
+ %code production/*
+ are supported
+ .form-group
+ %label.col-md-2.text-right{ for: 'merge_access_level_attributes' }
+ Allowed to merge:
+ .col-md-10
+ = dropdown_tag('Select',
+ options: { toggle_class: 'js-allowed-to-merge wide',
+ data: { field_name: 'protected_branch[merge_access_level_attributes][access_level]', input_id: 'merge_access_level_attributes' }})
+ .form-group
+ %label.col-md-2.text-right{ for: 'push_access_level_attributes' }
+ Allowed to push:
+ .col-md-10
+ = dropdown_tag('Select',
+ options: { toggle_class: 'js-allowed-to-push wide',
+ data: { field_name: 'protected_branch[push_access_level_attributes][access_level]', input_id: 'push_access_level_attributes' }})
+
+ .panel-footer
+ = f.submit 'Protect', class: 'btn-create btn', disabled: true
diff --git a/app/views/projects/protected_branches/_dropdown.html.haml b/app/views/projects/protected_branches/_dropdown.html.haml
index b803d932e67..a9e27df5a87 100644
--- a/app/views/projects/protected_branches/_dropdown.html.haml
+++ b/app/views/projects/protected_branches/_dropdown.html.haml
@@ -1,17 +1,15 @@
= f.hidden_field(:name)
-= dropdown_tag("Protected Branch",
- options: { title: "Pick protected branch", toggle_class: 'js-protected-branch-select js-filter-submit',
+= dropdown_tag('Select branch or create wildcard',
+ options: { toggle_class: 'js-protected-branch-select js-filter-submit wide',
filter: true, dropdown_class: "dropdown-menu-selectable", placeholder: "Search protected branches",
footer_content: true,
data: { show_no: true, show_any: true, show_upcoming: true,
selected: params[:protected_branch_name],
project_id: @project.try(:id) } }) do
- %ul.dropdown-footer-list.hidden.protected-branch-select-footer-list
+ %ul.dropdown-footer-list
%li
= link_to '#', title: "New Protected Branch", class: "create-new-protected-branch" do
- Create new
-
-:javascript
- new ProtectedBranchSelect();
+ Create wildcard
+ %code
diff --git a/app/views/projects/protected_branches/_protected_branch.html.haml b/app/views/projects/protected_branches/_protected_branch.html.haml
index 498e412235e..e2e01ee78f8 100644
--- a/app/views/projects/protected_branches/_protected_branch.html.haml
+++ b/app/views/projects/protected_branches/_protected_branch.html.haml
@@ -1,5 +1,4 @@
-- url = namespace_project_protected_branch_path(@project.namespace, @project, protected_branch)
-%tr
+%tr.js-protected-branch-edit-form{ data: { url: namespace_project_protected_branch_path(@project.namespace, @project, protected_branch), branch_id: protected_branch.id } }
%td
= protected_branch.name
- if @project.root_ref?(protected_branch.name)
@@ -16,14 +15,14 @@
(branch was removed from repository)
%td
= hidden_field_tag "allowed_to_merge_#{protected_branch.id}", protected_branch.merge_access_level.access_level
- = dropdown_tag(protected_branch.merge_access_level.humanize,
- options: { title: "Allowed to merge", toggle_class: 'allowed-to-merge', dropdown_class: 'dropdown-menu-selectable merge',
- data: { field_name: "allowed_to_merge_#{protected_branch.id}", url: url, id: protected_branch.id, type: "merge_access_level" }})
+ = dropdown_tag( (protected_branch.merge_access_level.humanize || 'Select') ,
+ options: { toggle_class: 'js-allowed-to-merge', dropdown_class: 'dropdown-menu-selectable js-allowed-to-merge-container',
+ data: { field_name: "allowed_to_merge_#{protected_branch.id}" }})
%td
= hidden_field_tag "allowed_to_push_#{protected_branch.id}", protected_branch.push_access_level.access_level
- = dropdown_tag(protected_branch.push_access_level.humanize,
- options: { title: "Allowed to push", toggle_class: 'allowed-to-push', dropdown_class: 'dropdown-menu-selectable push',
- data: { field_name: "allowed_to_push_#{protected_branch.id}", url: url, id: protected_branch.id, type: "push_access_level" }})
+ = dropdown_tag( (protected_branch.push_access_level.humanize || 'Select') ,
+ options: { toggle_class: 'js-allowed-to-push', dropdown_class: 'dropdown-menu-selectable js-allowed-to-push-container',
+ data: { field_name: "allowed_to_push_#{protected_branch.id}" }})
- if can_admin_project
%td
- = link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, protected_branch], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-warning btn-sm pull-right"
+ = link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, protected_branch], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: 'btn btn-warning'
diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml
index 4efe44c7233..49dcc9a6ba4 100644
--- a/app/views/projects/protected_branches/index.html.haml
+++ b/app/views/projects/protected_branches/index.html.haml
@@ -14,41 +14,7 @@
%li prevent <strong>anyone</strong> from deleting the branch
%p.append-bottom-0 Read more about #{link_to "protected branches", help_page_path("user/project/protected_branches"), class: "underlined-link"} and #{link_to "project permissions", help_page_path("user/permissions"), class: "underlined-link"}.
.col-lg-9
- %h5.prepend-top-0
- Protect a branch
- if can? current_user, :admin_project, @project
- = form_for [@project.namespace.becomes(Namespace), @project, @protected_branch] do |f|
- = form_errors(@protected_branch)
+ = render 'create_protected_branch'
- .form-group
- = f.label :name, "Branch", class: "label-light"
- = render partial: "dropdown", locals: { f: f }
- %p.help-block
- = link_to "Wildcards", help_page_path('user/project/protected_branches', anchor: "wildcard-protected-branches")
- such as
- %code *-stable
- or
- %code production/*
- are supported.
-
- .form-group
- = hidden_field_tag 'protected_branch[merge_access_level_attributes][access_level]'
- = label_tag "Allowed to merge: ", nil, class: "label-light append-bottom-0"
- = dropdown_tag("<Make a selection>",
- options: { title: "Allowed to merge", toggle_class: 'allowed-to-merge',
- dropdown_class: 'dropdown-menu-selectable',
- data: { field_name: "protected_branch[merge_access_level_attributes][access_level]" }})
-
- .form-group
- = hidden_field_tag 'protected_branch[push_access_level_attributes][access_level]'
- = label_tag "Allowed to push: ", nil, class: "label-light append-bottom-0"
- = dropdown_tag("<Make a selection>",
- options: { title: "Allowed to push", toggle_class: 'allowed-to-push',
- dropdown_class: 'dropdown-menu-selectable',
- data: { field_name: "protected_branch[push_access_level_attributes][access_level]" }})
-
-
- = f.submit "Protect", class: "btn-create btn protect-branch-btn", disabled: true
-
- %hr
= render "branches_list"
diff --git a/app/views/shared/web_hooks/_form.html.haml b/app/views/shared/web_hooks/_form.html.haml
index 106161d6515..a672c28de39 100644
--- a/app/views/shared/web_hooks/_form.html.haml
+++ b/app/views/shared/web_hooks/_form.html.haml
@@ -19,7 +19,7 @@
= f.label :token, "Secret Token", class: 'label-light'
= f.text_field :token, class: "form-control", placeholder: ''
%p.help-block
- Use this token to validate received payloads
+ Use this token to validate received payloads. It will be sent with the request in the X-Gitlab-Token HTTP header.
.form-group
= f.label :url, "Trigger", class: 'label-light'
%ul.list-unstyled
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index 09035a7cf2d..a9a2b716005 100644
--- a/app/workers/post_receive.rb
+++ b/app/workers/post_receive.rb
@@ -10,6 +10,10 @@ class PostReceive
log("Check gitlab.yml config for correct repositories.storages values. No repository storage path matches \"#{repo_path}\"")
end
+ changes = Base64.decode64(changes) unless changes.include?(' ')
+ # Use Sidekiq.logger so arguments can be correlated with execution
+ # time and thread ID's.
+ Sidekiq.logger.info "changes: #{changes.inspect}" if ENV['SIDEKIQ_LOG_ARGUMENTS']
post_received = Gitlab::GitPostReceive.new(repo_path, identifier, changes)
if post_received.project.nil?
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 73977341b73..a0a8f88584c 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -100,6 +100,9 @@ Devise.setup do |config|
# secure: true in order to force SSL only cookies.
# config.cookie_options = {}
+ # Send a notification email when the user's password is changed
+ config.send_password_change_notification = true
+
# ==> Configuration for :validatable
# Range for password length. Default is 6..128.
config.password_length = 8..128
diff --git a/db/fixtures/development/14_builds.rb b/db/fixtures/development/14_builds.rb
index 124704cb451..e65abe4ef77 100644
--- a/db/fixtures/development/14_builds.rb
+++ b/db/fixtures/development/14_builds.rb
@@ -1,6 +1,6 @@
class Gitlab::Seeder::Builds
STAGES = %w[build notify_build test notify_test deploy notify_deploy]
-
+
def initialize(project)
@project = project
end
@@ -8,26 +8,26 @@ class Gitlab::Seeder::Builds
def seed!
pipelines.each do |pipeline|
begin
- build_create!(pipeline, name: 'build:linux', stage: 'build')
- build_create!(pipeline, name: 'build:osx', stage: 'build')
+ build_create!(pipeline, name: 'build:linux', stage: 'build', status_event: :success)
+ build_create!(pipeline, name: 'build:osx', stage: 'build', status_event: :success)
- build_create!(pipeline, name: 'slack post build', stage: 'notify_build')
+ build_create!(pipeline, name: 'slack post build', stage: 'notify_build', status_event: :success)
- build_create!(pipeline, name: 'rspec:linux', stage: 'test')
- build_create!(pipeline, name: 'rspec:windows', stage: 'test')
- build_create!(pipeline, name: 'rspec:windows', stage: 'test')
- build_create!(pipeline, name: 'rspec:osx', stage: 'test')
- build_create!(pipeline, name: 'spinach:linux', stage: 'test')
- build_create!(pipeline, name: 'spinach:osx', stage: 'test')
- build_create!(pipeline, name: 'cucumber:linux', stage: 'test')
- build_create!(pipeline, name: 'cucumber:osx', stage: 'test')
+ build_create!(pipeline, name: 'rspec:linux', stage: 'test', status_event: :success)
+ build_create!(pipeline, name: 'rspec:windows', stage: 'test', status_event: :success)
+ build_create!(pipeline, name: 'rspec:windows', stage: 'test', status_event: :success)
+ build_create!(pipeline, name: 'rspec:osx', stage: 'test', status_event: :success)
+ build_create!(pipeline, name: 'spinach:linux', stage: 'test', status: :pending)
+ build_create!(pipeline, name: 'spinach:osx', stage: 'test', status_event: :cancel)
+ build_create!(pipeline, name: 'cucumber:linux', stage: 'test', status_event: :run)
+ build_create!(pipeline, name: 'cucumber:osx', stage: 'test', status_event: :drop)
- build_create!(pipeline, name: 'slack post test', stage: 'notify_test')
+ build_create!(pipeline, name: 'slack post test', stage: 'notify_test', status_event: :success)
- build_create!(pipeline, name: 'staging', stage: 'deploy', environment: 'staging')
- build_create!(pipeline, name: 'production', stage: 'deploy', environment: 'production', when: 'manual')
+ build_create!(pipeline, name: 'staging', stage: 'deploy', environment: 'staging', status_event: :success)
+ build_create!(pipeline, name: 'production', stage: 'deploy', environment: 'production', when: 'manual', status: :success)
- commit_status_create!(pipeline, name: 'jenkins')
+ commit_status_create!(pipeline, name: 'jenkins', status: :success)
print '.'
rescue ActiveRecord::RecordInvalid
@@ -48,7 +48,7 @@ class Gitlab::Seeder::Builds
def build_create!(pipeline, opts = {})
attributes = build_attributes_for(pipeline, opts)
- build = Ci::Build.new(attributes)
+ build = Ci::Build.create!(attributes)
if opts[:name].start_with?('build')
artifacts_cache_file(artifacts_archive_path) do |file|
@@ -60,23 +60,20 @@ class Gitlab::Seeder::Builds
end
end
- build.save!
- build.update(status: build_status)
-
if %w(running success failed).include?(build.status)
# We need to set build trace after saving a build (id required)
build.trace = FFaker::Lorem.paragraphs(6).join("\n\n")
end
end
-
+
def commit_status_create!(pipeline, opts = {})
attributes = commit_status_attributes_for(pipeline, opts)
- GenericCommitStatus.create(attributes)
+ GenericCommitStatus.create!(attributes)
end
-
+
def commit_status_attributes_for(pipeline, opts)
{ name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]),
- ref: 'master', user: build_user, project: @project, pipeline: pipeline,
+ ref: 'master', tag: false, user: build_user, project: @project, pipeline: pipeline,
created_at: Time.now, updated_at: Time.now
}.merge(opts)
end
diff --git a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb b/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb
index fa93936ced7..1db0df92bec 100644
--- a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb
+++ b/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb
@@ -14,7 +14,7 @@ class MoveFromDevelopersCanMergeToProtectedBranchesMergeAccess < ActiveRecord::M
def up
execute <<-HEREDOC
INSERT into protected_branch_merge_access_levels (protected_branch_id, access_level, created_at, updated_at)
- SELECT id, (CASE WHEN developers_can_merge THEN 1 ELSE 0 END), now(), now()
+ SELECT id, (CASE WHEN developers_can_merge THEN 30 ELSE 40 END), now(), now()
FROM protected_branches
HEREDOC
end
@@ -23,7 +23,7 @@ class MoveFromDevelopersCanMergeToProtectedBranchesMergeAccess < ActiveRecord::M
execute <<-HEREDOC
UPDATE protected_branches SET developers_can_merge = TRUE
WHERE id IN (SELECT protected_branch_id FROM protected_branch_merge_access_levels
- WHERE access_level = 1);
+ WHERE access_level = 30);
HEREDOC
end
end
diff --git a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb
index 56f6159d1d8..5c3e189bb5b 100644
--- a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb
+++ b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb
@@ -14,7 +14,7 @@ class MoveFromDevelopersCanPushToProtectedBranchesPushAccess < ActiveRecord::Mig
def up
execute <<-HEREDOC
INSERT into protected_branch_push_access_levels (protected_branch_id, access_level, created_at, updated_at)
- SELECT id, (CASE WHEN developers_can_push THEN 1 ELSE 0 END), now(), now()
+ SELECT id, (CASE WHEN developers_can_push THEN 30 ELSE 40 END), now(), now()
FROM protected_branches
HEREDOC
end
@@ -23,7 +23,7 @@ class MoveFromDevelopersCanPushToProtectedBranchesPushAccess < ActiveRecord::Mig
execute <<-HEREDOC
UPDATE protected_branches SET developers_can_push = TRUE
WHERE id IN (SELECT protected_branch_id FROM protected_branch_push_access_levels
- WHERE access_level = 1);
+ WHERE access_level = 30);
HEREDOC
end
end
diff --git a/db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb b/db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb
index f563f660ddf..52a9819c628 100644
--- a/db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb
+++ b/db/migrate/20160705055809_remove_developers_can_push_from_protected_branches.rb
@@ -14,6 +14,6 @@ class RemoveDevelopersCanPushFromProtectedBranches < ActiveRecord::Migration
end
def down
- add_column_with_default(:protected_branches, :developers_can_push, :boolean, default: false, null: false)
+ add_column_with_default(:protected_branches, :developers_can_push, :boolean, default: false, allow_null: false)
end
end
diff --git a/db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb b/db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb
index aa71e06d36e..4a7bde7f9f3 100644
--- a/db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb
+++ b/db/migrate/20160705055813_remove_developers_can_merge_from_protected_branches.rb
@@ -14,6 +14,6 @@ class RemoveDevelopersCanMergeFromProtectedBranches < ActiveRecord::Migration
end
def down
- add_column_with_default(:protected_branches, :developers_can_merge, :boolean, default: false, null: false)
+ add_column_with_default(:protected_branches, :developers_can_merge, :boolean, default: false, allow_null: false)
end
end
diff --git a/db/migrate/20160804150737_add_timestamps_to_members_again.rb b/db/migrate/20160804150737_add_timestamps_to_members_again.rb
new file mode 100644
index 00000000000..6691ba57fbb
--- /dev/null
+++ b/db/migrate/20160804150737_add_timestamps_to_members_again.rb
@@ -0,0 +1,21 @@
+# rubocop:disable all
+# 20141121133009_add_timestamps_to_members.rb was meant to ensure that all
+# rows in the members table had created_at and updated_at set, following an
+# error in a previous migration. This failed to set all rows in at least one
+# case: https://gitlab.com/gitlab-org/gitlab-ce/issues/20568
+#
+# Why this happened is lost in the mists of time, so repeat the SQL query
+# without speculation, just in case more than one person was affected.
+class AddTimestampsToMembersAgain < ActiveRecord::Migration
+ DOWNTIME = false
+
+ def up
+ execute "UPDATE members SET created_at = NOW() WHERE created_at IS NULL"
+ execute "UPDATE members SET updated_at = NOW() WHERE updated_at IS NULL"
+ end
+
+ def down
+ # no change
+ end
+
+end
diff --git a/db/schema.rb b/db/schema.rb
index 8f3c41821a7..2837c47185d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160802010328) do
+ActiveRecord::Schema.define(version: 20160804150737) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
diff --git a/doc/administration/build_artifacts.md b/doc/administration/build_artifacts.md
new file mode 100644
index 00000000000..64353f7282b
--- /dev/null
+++ b/doc/administration/build_artifacts.md
@@ -0,0 +1,90 @@
+# Build artifacts administration
+
+>**Notes:**
+>- Introduced in GitLab 8.2 and GitLab Runner 0.7.0.
+>- Starting from GitLab 8.4 and GitLab Runner 1.0, the artifacts archive format
+ changed to `ZIP`.
+>- This is the administration documentation. For the user guide see
+ [user/project/builds/artifacts.md](../user/project/builds/artifacts.md).
+
+Artifacts is a list of files and directories which are attached to a build
+after it completes successfully. This feature is enabled by default in all
+GitLab installations. Keep reading if you want to know how to disable it.
+
+## Disabling build artifacts
+
+To disable artifacts site-wide, follow the steps below.
+
+---
+
+**In Omnibus installations:**
+
+1. Edit `/etc/gitlab/gitlab.rb` and add the following line:
+
+ ```ruby
+ gitlab_rails['artifacts_enabled'] = false
+ ```
+
+1. Save the file and [reconfigure GitLab][] for the changes to take effect.
+
+---
+
+**In installations from source:**
+
+1. Edit `/home/git/gitlab/config/gitlab.yml` and add or amend the following lines:
+
+ ```yaml
+ artifacts:
+ enabled: false
+ ```
+
+1. Save the file and [restart GitLab][] for the changes to take effect.
+
+## Storing build artifacts
+
+After a successful build, GitLab Runner uploads an archive containing the build
+artifacts to GitLab.
+
+To change the location where the artifacts are stored, follow the steps below.
+
+---
+
+**In Omnibus installations:**
+
+_The artifacts are stored by default in
+`/var/opt/gitlab/gitlab-rails/shared/artifacts`._
+
+1. To change the storage path for example to `/mnt/storage/artifacts`, edit
+ `/etc/gitlab/gitlab.rb` and add the following line:
+
+ ```ruby
+ gitlab_rails['artifacts_path'] = "/mnt/storage/artifacts"
+ ```
+
+1. Save the file and [reconfigure GitLab][] for the changes to take effect.
+
+---
+
+**In installations from source:**
+
+_The artifacts are stored by default in
+`/home/git/gitlab/shared/artifacts`._
+
+1. To change the storage path for example to `/mnt/storage/artifacts`, edit
+ `/home/git/gitlab/config/gitlab.yml` and add or amend the following lines:
+
+ ```yaml
+ artifacts:
+ enabled: true
+ path: /mnt/storage/artifacts
+ ```
+
+1. Save the file and [restart GitLab][] for the changes to take effect.
+
+## Set the maximum file size of the artifacts
+
+Provided the artifacts are enabled, you can change the maximum file size of the
+artifacts through the [Admin area settings](../user/admin_area/settings/continuous_integration#maximum-artifacts-size).
+
+[reconfigure gitlab]: restart_gitlab.md "How to restart GitLab"
+[restart gitlab]: restart_gitlab.md "How to restart GitLab"
diff --git a/doc/administration/container_registry.md b/doc/administration/container_registry.md
index d5d43303454..b5db575477c 100644
--- a/doc/administration/container_registry.md
+++ b/doc/administration/container_registry.md
@@ -1,7 +1,6 @@
# GitLab Container Registry Administration
-> **Note:**
-This feature was [introduced][ce-4040] in GitLab 8.8.
+> [Introduced][ce-4040] in GitLab 8.8.
With the Docker Container Registry integrated into GitLab, every project can
have its own space to store its Docker images.
diff --git a/doc/administration/custom_hooks.md b/doc/administration/custom_hooks.md
index e3306c22d3f..0387d730489 100644
--- a/doc/administration/custom_hooks.md
+++ b/doc/administration/custom_hooks.md
@@ -44,8 +44,7 @@ as appropriate.
## Custom error messages
->**Note:**
-This feature was [introduced][5073] in GitLab 8.10.
+> [Introduced][5073] in GitLab 8.10.
If the commit is declined or an error occurs during the Git hook check,
the STDERR or STDOUT message of the hook will be present in GitLab's UI.
diff --git a/doc/administration/housekeeping.md b/doc/administration/housekeeping.md
index a5fa7d358a2..34b4f1faa94 100644
--- a/doc/administration/housekeeping.md
+++ b/doc/administration/housekeeping.md
@@ -1,6 +1,6 @@
# Housekeeping
-_**Note:** This feature was [introduced][ce-2371] in GitLab 8.4_
+> [Introduced][ce-2371] in GitLab 8.4.
---
diff --git a/doc/administration/raketasks/project_import_export.md b/doc/administration/raketasks/project_import_export.md
index c212059b9d5..39b1883375e 100644
--- a/doc/administration/raketasks/project_import_export.md
+++ b/doc/administration/raketasks/project_import_export.md
@@ -1,13 +1,14 @@
# Project import/export
>**Note:**
- - This feature was [introduced][ce-3050] in GitLab 8.9
- - Importing will not be possible if the import instance version is lower
- than that of the exporter.
- - For existing installations, the project import option has to be enabled in
- application settings (`/admin/application_settings`) under 'Import sources'.
- - The exports are stored in a temporary [shared directory][tmp] and are deleted
- every 24 hours by a specific worker.
+>
+> - [Introduced][ce-3050] in GitLab 8.9.
+> - Importing will not be possible if the import instance version is lower
+> than that of the exporter.
+> - For existing installations, the project import option has to be enabled in
+> application settings (`/admin/application_settings`) under 'Import sources'.
+> - The exports are stored in a temporary [shared directory][tmp] and are deleted
+> every 24 hours by a specific worker.
The GitLab Import/Export version can be checked by using:
diff --git a/doc/administration/repository_checks.md b/doc/administration/repository_checks.md
index 4172b604cec..bc2b1f20ed3 100644
--- a/doc/administration/repository_checks.md
+++ b/doc/administration/repository_checks.md
@@ -1,8 +1,7 @@
# Repository checks
->**Note:**
-This feature was [introduced][ce-3232] in GitLab 8.7. It is OFF by
-default because it still causes too many false alarms.
+> [Introduced][ce-3232] in GitLab 8.7. It is OFF by default because it still
+causes too many false alarms.
Git has a built-in mechanism, [git fsck][git-fsck], to verify the
integrity of all data committed to a repository. GitLab administrators
diff --git a/doc/api/README.md b/doc/api/README.md
index d1e6c54c521..21141d350cf 100644
--- a/doc/api/README.md
+++ b/doc/api/README.md
@@ -81,7 +81,7 @@ Read more about [GitLab as an OAuth2 client](oauth2.md).
### Personal Access Tokens
-> **Note:** This feature was [introduced][ce-3749] in GitLab 8.8
+> [Introduced][ce-3749] in GitLab 8.8.
You can create as many personal access tokens as you like from your GitLab
profile (`/profile/personal_access_tokens`); perhaps one for each application
diff --git a/doc/api/award_emoji.md b/doc/api/award_emoji.md
index 796b3680a75..158fb189005 100644
--- a/doc/api/award_emoji.md
+++ b/doc/api/award_emoji.md
@@ -1,6 +1,6 @@
# Award Emoji
- >**Note:** This feature was introduced in GitLab 8.9
+> [Introduced][ce-4575] in GitLab 8.9.
An awarded emoji tells a thousand words, and can be awarded on issues, merge
requests and notes/comments. Issues, merge requests and notes are further called
@@ -365,3 +365,5 @@ Example Response:
"awardable_type": "Note"
}
```
+
+[ce-4575]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4575
diff --git a/doc/api/deploy_keys.md b/doc/api/deploy_keys.md
index 4e620ccc81a..a288de5fc97 100644
--- a/doc/api/deploy_keys.md
+++ b/doc/api/deploy_keys.md
@@ -159,3 +159,51 @@ Example response:
"id" : 13
}
```
+
+## Enable a deploy key
+
+Enables a deploy key for a project so this can be used. Returns the enabled key, with a status code 201 when successful.
+
+```bash
+curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/deploy_keys/13/enable
+```
+
+| Attribute | Type | Required | Description |
+| --------- | ---- | -------- | ----------- |
+| `id` | integer | yes | The ID of the project |
+| `key_id` | integer | yes | The ID of the deploy key |
+
+Example response:
+
+```json
+{
+ "key" : "ssh-rsa AAAA...",
+ "id" : 12,
+ "title" : "My deploy key",
+ "created_at" : "2015-08-29T12:44:31.550Z"
+}
+```
+
+## Disable a deploy key
+
+Disable a deploy key for a project. Returns the disabled key.
+
+```bash
+curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/deploy_keys/13/disable
+```
+
+| Attribute | Type | Required | Description |
+| --------- | ---- | -------- | ----------- |
+| `id` | integer | yes | The ID of the project |
+| `key_id` | integer | yes | The ID of the deploy key |
+
+Example response:
+
+```json
+{
+ "key" : "ssh-rsa AAAA...",
+ "id" : 12,
+ "title" : "My deploy key",
+ "created_at" : "2015-08-29T12:44:31.550Z"
+}
+```
diff --git a/doc/api/repository_files.md b/doc/api/repository_files.md
index 623063f357b..1b8ee88b4ed 100644
--- a/doc/api/repository_files.md
+++ b/doc/api/repository_files.md
@@ -12,6 +12,10 @@ Allows you to receive information about file in repository like name, size, cont
GET /projects/:id/repository/files
```
+```bash
+curl -X GET -H 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' 'https://gitlab.example.com/api/v3/projects/13083/repository/files?file_path=app/models/key.rb&ref=master'
+```
+
Example response:
```json
@@ -39,6 +43,10 @@ Parameters:
POST /projects/:id/repository/files
```
+```bash
+curl -X POST -H 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' 'https://gitlab.example.com/api/v3/projects/13083/repository/files?file_path=app/project.rb&branch_name=master&content=some%20content&commit_message=create%20a%20new%20file'
+```
+
Example response:
```json
@@ -62,6 +70,10 @@ Parameters:
PUT /projects/:id/repository/files
```
+```bash
+curl -X PUT -H 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' 'https://gitlab.example.com/api/v3/projects/13083/repository/files?file_path=app/project.rb&branch_name=master&content=some%20other%20content&commit_message=update%20file'
+```
+
Example response:
```json
@@ -94,6 +106,10 @@ Currently gitlab-shell has a boolean return code, preventing GitLab from specify
DELETE /projects/:id/repository/files
```
+```bash
+curl -X PUT -H 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' 'https://gitlab.example.com/api/v3/projects/13083/repository/files?file_path=app/project.rb&branch_name=master&commit_message=delete%20file'
+```
+
Example response:
```json
diff --git a/doc/api/todos.md b/doc/api/todos.md
index 937c71de386..c9e1e83e28a 100644
--- a/doc/api/todos.md
+++ b/doc/api/todos.md
@@ -1,6 +1,6 @@
# Todos
-**Note:** This feature was [introduced][ce-3188] in GitLab 8.10
+> [Introduced][ce-3188] in GitLab 8.10.
## Get a list of todos
diff --git a/doc/ci/README.md b/doc/ci/README.md
index 0833027f91d..10ce4ac8940 100644
--- a/doc/ci/README.md
+++ b/doc/ci/README.md
@@ -14,7 +14,7 @@
- [Use variables in your `.gitlab-ci.yml`](variables/README.md)
- [Use SSH keys in your build environment](ssh_keys/README.md)
- [Trigger builds through the API](triggers/README.md)
-- [Build artifacts](build_artifacts/README.md)
+- [Build artifacts](../user/project/builds/artifacts.md)
- [User permissions](../user/permissions.md#gitlab-ci)
- [API](../api/ci/README.md)
- [CI services (linked docker containers)](services/README.md)
diff --git a/doc/ci/build_artifacts/README.md b/doc/ci/build_artifacts/README.md
index 9553bb11e9d..05605f10fb4 100644
--- a/doc/ci/build_artifacts/README.md
+++ b/doc/ci/build_artifacts/README.md
@@ -1,175 +1,4 @@
-# Introduction to build artifacts
+This document was moved to:
-Artifacts is a list of files and directories which are attached to a build
-after it completes successfully. This feature is enabled by default in all GitLab installations.
-
-_If you are searching for ways to use artifacts, jump to
-[Defining artifacts in `.gitlab-ci.yml`](#defining-artifacts-in-gitlab-ciyml)._
-
-Since GitLab 8.2 and [GitLab Runner] 0.7.0, build artifacts that are created by
-GitLab Runner are uploaded to GitLab and are downloadable as a single archive
-(`tar.gz`) using the GitLab UI.
-
-Starting from GitLab 8.4 and GitLab Runner 1.0, the artifacts archive format
-changed to `ZIP`, and it is now possible to browse its contents, with the added
-ability of downloading the files separately.
-
-**Note:**
-The artifacts browser will be available only for new artifacts that are sent
-to GitLab using GitLab Runner version 1.0 and up. It will not be possible to
-browse old artifacts already uploaded to GitLab.
-
-## Disabling build artifacts
-
-To disable artifacts site-wide, follow the steps below.
-
----
-
-**In Omnibus installations:**
-
-1. Edit `/etc/gitlab/gitlab.rb` and add the following line:
-
- ```ruby
- gitlab_rails['artifacts_enabled'] = false
- ```
-
-1. Save the file and [reconfigure GitLab][] for the changes to take effect.
-
----
-
-**In installations from source:**
-
-1. Edit `/home/git/gitlab/config/gitlab.yml` and add or amend the following lines:
-
- ```yaml
- artifacts:
- enabled: false
- ```
-
-1. Save the file and [restart GitLab][] for the changes to take effect.
-
-## Defining artifacts in `.gitlab-ci.yml`
-
-A simple example of using the artifacts definition in `.gitlab-ci.yml` would be
-the following:
-
-```yaml
-pdf:
- script: xelatex mycv.tex
- artifacts:
- paths:
- - mycv.pdf
-```
-
-A job named `pdf` calls the `xelatex` command in order to build a pdf file from
-the latex source file `mycv.tex`. We then define the `artifacts` paths which in
-turn are defined with the `paths` keyword. All paths to files and directories
-are relative to the repository that was cloned during the build.
-
-For more examples on artifacts, follow the
-[separate artifacts yaml documentation](../yaml/README.md#artifacts).
-
-## Storing build artifacts
-
-After a successful build, GitLab Runner uploads an archive containing the build
-artifacts to GitLab.
-
-To change the location where the artifacts are stored, follow the steps below.
-
----
-
-**In Omnibus installations:**
-
-_The artifacts are stored by default in
-`/var/opt/gitlab/gitlab-rails/shared/artifacts`._
-
-1. To change the storage path for example to `/mnt/storage/artifacts`, edit
- `/etc/gitlab/gitlab.rb` and add the following line:
-
- ```ruby
- gitlab_rails['artifacts_path'] = "/mnt/storage/artifacts"
- ```
-
-1. Save the file and [reconfigure GitLab][] for the changes to take effect.
-
----
-
-**In installations from source:**
-
-_The artifacts are stored by default in
-`/home/git/gitlab/shared/artifacts`._
-
-1. To change the storage path for example to `/mnt/storage/artifacts`, edit
- `/home/git/gitlab/config/gitlab.yml` and add or amend the following lines:
-
- ```yaml
- artifacts:
- enabled: true
- path: /mnt/storage/artifacts
- ```
-
-1. Save the file and [restart GitLab][] for the changes to take effect.
-
-## Browsing build artifacts
-
-When GitLab receives an artifacts archive, an archive metadata file is also
-generated. This metadata file describes all the entries that are located in the
-artifacts archive itself. The metadata file is in a binary format, with
-additional GZIP compression.
-
-GitLab does not extract the artifacts archive in order to save space, memory
-and disk I/O. It instead inspects the metadata file which contains all the
-relevant information. This is especially important when there is a lot of
-artifacts, or an archive is a very large file.
-
----
-
-After a successful build, if you visit the build's specific page, you can see
-that there are two buttons.
-
-One is for downloading the artifacts archive and the other for browsing its
-contents.
-
-![Build artifacts browser button](img/build_artifacts_browser_button.png)
-
----
-
-The archive browser shows the name and the actual file size of each file in the
-archive. If your artifacts contained directories, then you are also able to
-browse inside them.
-
-Below you can see an image of three different file formats, as well as two
-directories.
-
-![Build artifacts browser](img/build_artifacts_browser.png)
-
----
-
-## Downloading build artifacts
-
-If you need to download the whole archive, there are buttons in various places
-inside GitLab that make that possible.
-
-1. While on the builds page, you can see the download icon for each build's
- artifacts archive in the right corner
-
-1. While inside a specific build, you are presented with a download button
- along with the one that browses the archive
-
-1. And finally, when browsing an archive you can see the download button at
- the top right corner
-
----
-
-Note that GitLab does not extract the entire artifacts archive to send just a
-single file to the user.
-
-When clicking on a specific file, [GitLab Workhorse] extracts it from the
-archive and the download begins.
-
-This implementation saves space, memory and disk I/O.
-
-[gitlab runner]: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner "GitLab Runner repository"
-[reconfigure gitlab]: ../../administration/restart_gitlab.md "How to restart GitLab documentation"
-[restart gitlab]: ../../administration/restart_gitlab.md "How to restart GitLab documentation"
-[gitlab workhorse]: https://gitlab.com/gitlab-org/gitlab-workhorse "GitLab Workhorse repository"
+- [user/project/builds/artifacts.md](../../user/project/builds/artifacts.md) - user guide
+- [administration/build_artifacts.md](../../administration/build_artifacts.md) - administrator guide
diff --git a/doc/ci/build_artifacts/img/build_artifacts_browser.png b/doc/ci/build_artifacts/img/build_artifacts_browser.png
deleted file mode 100644
index 59cf2b8746b..00000000000
--- a/doc/ci/build_artifacts/img/build_artifacts_browser.png
+++ /dev/null
Binary files differ
diff --git a/doc/ci/build_artifacts/img/build_artifacts_browser_button.png b/doc/ci/build_artifacts/img/build_artifacts_browser_button.png
deleted file mode 100644
index 7801c2e6fa6..00000000000
--- a/doc/ci/build_artifacts/img/build_artifacts_browser_button.png
+++ /dev/null
Binary files differ
diff --git a/doc/ci/triggers/README.md b/doc/ci/triggers/README.md
index 5c316510d0e..57a12526363 100644
--- a/doc/ci/triggers/README.md
+++ b/doc/ci/triggers/README.md
@@ -1,6 +1,6 @@
# Triggering Builds through the API
-_**Note:** This feature was [introduced][ci-229] in GitLab CE 7.14_
+> [Introduced][ci-229] in GitLab CE 7.14.
Triggers can be used to force a rebuild of a specific branch, tag or commit,
with an API call.
diff --git a/doc/container_registry/README.md b/doc/container_registry/README.md
index 3db351811a8..047a0b08406 100644
--- a/doc/container_registry/README.md
+++ b/doc/container_registry/README.md
@@ -1,8 +1,7 @@
# GitLab Container Registry
-> **Note:**
-This feature was [introduced][ce-4040] in GitLab 8.8. Docker Registry manifest
-v1 support was added in GitLab 8.9 to support Docker versions earlier than 1.10.
+> [Introduced][ce-4040] in GitLab 8.8. Docker Registry manifest
+`v1` support was added in GitLab 8.9 to support Docker versions earlier than 1.10.
> **Note:**
This document is about the user guide. To learn how to enable GitLab Container
diff --git a/doc/development/README.md b/doc/development/README.md
index 11aa50b89af..7b5f7ff8ad3 100644
--- a/doc/development/README.md
+++ b/doc/development/README.md
@@ -31,6 +31,7 @@
- [Rake tasks](rake_tasks.md) for development
- [Shell commands](shell_commands.md) in the GitLab codebase
- [Sidekiq debugging](sidekiq_debugging.md)
+- [What requires downtime?](what_requires_downtime.md)
## Compliance
diff --git a/doc/development/doc_styleguide.md b/doc/development/doc_styleguide.md
index 3a3597bccaa..994005f929f 100644
--- a/doc/development/doc_styleguide.md
+++ b/doc/development/doc_styleguide.md
@@ -3,12 +3,64 @@
This styleguide recommends best practices to improve documentation and to keep
it organized and easy to find.
-## Naming
+## Location and naming of documents
-- When creating a new document and it has more than one word in its name,
- make sure to use underscores instead of spaces or dashes (`-`). For example,
- a proper naming would be `import_projects_from_github.md`. The same rule
- applies to images.
+>**Note:**
+These guidelines derive from the discussion taken place in issue [#3349](ce-3349).
+
+The documentation hierarchy can be vastly improved by providing a better layout
+and organization of directories.
+
+Having a structured document layout, we will be able to have meaningful URLs
+like `docs.gitlab.com/user/project/merge_requests.html`. With this pattern,
+you can immediately tell that you are navigating a user related documentation
+and is about the project and its merge requests.
+
+The table below shows what kind of documentation goes where.
+
+| Directory | What belongs here |
+| --------- | -------------- |
+| `doc/user/` | User related documentation. Anything that can be done within the GitLab UI goes here including `/admin`. |
+| `doc/administration/` | Documentation that requires the user to have access to the server where GitLab is installed. The admin settings that can be accessed via GitLab's interface go under `doc/user/admin_area/`. |
+| `doc/api/` | API related documentation. |
+| `doc/development/` | Documentation related to the development of GitLab. Any styleguides should go here. |
+| `doc/legal/` | Legal documents about contributing to GitLab. |
+| `doc/install/`| Probably the most visited directory, since `installation.md` is there. Ideally this should go under `doc/administration/`, but it's best to leave it as-is in order to avoid confusion (still debated though). |
+| `doc/update/` | Same with `doc/install/`. Should be under `administration/`, but this is a well known location, better leave as-is, at least for now. |
+
+---
+
+**General rules:**
+
+1. The correct naming and location of a new document, is a combination
+ of the relative URL of the document in question and the GitLab Map design
+ that is used for UX purposes ([source][graffle], [image][gitlab-map]).
+1. When creating a new document and it has more than one word in its name,
+ make sure to use underscores instead of spaces or dashes (`-`). For example,
+ a proper naming would be `import_projects_from_github.md`. The same rule
+ applies to images.
+1. There are four main directories, `user`, `administration`, `api` and `development`.
+1. The `doc/user/` directory has five main subdirectories: `project/`, `group/`,
+ `profile/`, `dashboard/` and `admin_area/`.
+ 1. `doc/user/project/` should contain all project related documentation.
+ 1. `doc/user/group/` should contain all group related documentation.
+ 1. `doc/user/profile/` should contain all profile related documentation.
+ Every page you would navigate under `/profile` should have its own document,
+ i.e. `account.md`, `applications.md`, `emails.md`, etc.
+ 1. `doc/user/dashboard/` should contain all dashboard related documentation.
+ 1. `doc/user/admin_area/` should contain all admin related documentation
+ describing what can be achieved by accessing GitLab's admin interface
+ (_not to be confused with `doc/administration` where server access is
+ required_).
+ 1. Every category under `/admin/application_settings` should have its
+ own document located at `doc/user/admin_area/settings/`. For example,
+ the **Visibility and Access Controls** category should have a document
+ located at `doc/user/admin_area/settings/visibility_and_access_controls.md`.
+
+---
+
+If you are unsure where a document should live, you can ping `@axil` in your
+merge request.
## Text
@@ -103,15 +155,15 @@ Inside the document:
- Every piece of documentation that comes with a new feature should declare the
GitLab version that feature got introduced. Right below the heading add a
- note: `>**Note:** This feature was introduced in GitLab 8.3`
+ note: `> Introduced in GitLab 8.3.`.
- If possible every feature should have a link to the MR that introduced it.
The above note would be then transformed to:
- `>**Note:** This feature was [introduced][ce-1242] in GitLab 8.3`, where
+ `> [Introduced][ce-1242] in GitLab 8.3.`, where
the [link identifier](#links) is named after the repository (CE) and the MR
- number
+ number.
- If the feature is only in GitLab EE, don't forget to mention it, like:
- `>**Note:** This feature was introduced in GitLab EE 8.3`. Otherwise, leave
- this mention out
+ `> Introduced in GitLab EE 8.3.`. Otherwise, leave
+ this mention out.
## References
@@ -372,3 +424,6 @@ curl -X PUT -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" -d "domain_whitelist[]=*.ex
[single spaces]: http://www.slate.com/articles/technology/technology/2011/01/space_invaders.html
[gfm]: http://docs.gitlab.com/ce/markdown/markdown.html#newlines "GitLab flavored markdown documentation"
[doc-restart]: ../administration/restart_gitlab.md "GitLab restart documentation"
+[ce-3349]: https://gitlab.com/gitlab-org/gitlab-ce/issues/3349 "Documentation restructure"
+[graffle]: https://gitlab.com/gitlab-org/gitlab-design/blob/d8d39f4a87b90fb9ae89ca12dc565347b4900d5e/production/resources/gitlab-map.graffle
+[gitlab-map]: https://gitlab.com/gitlab-org/gitlab-design/raw/master/production/resources/gitlab-map.png
diff --git a/doc/development/newlines_styleguide.md b/doc/development/newlines_styleguide.md
new file mode 100644
index 00000000000..e03adcaadea
--- /dev/null
+++ b/doc/development/newlines_styleguide.md
@@ -0,0 +1,102 @@
+# Newlines styleguide
+
+This style guide recommends best practices for newlines in Ruby code.
+
+## Rule: separate code with newlines only when it makes sense from logic perspectice
+
+```ruby
+# bad
+def method
+ issue = Issue.new
+
+ issue.save
+
+ render json: issue
+end
+```
+
+```ruby
+# good
+def method
+ issue = Issue.new
+ issue.save
+
+ render json: issue
+end
+```
+
+## Rule: separate code and block with newlines
+
+### Newline before block
+
+```ruby
+# bad
+def method
+ issue = Issue.new
+ if issue.save
+ render json: issue
+ end
+end
+```
+
+```ruby
+# good
+def method
+ issue = Issue.new
+
+ if issue.save
+ render json: issue
+ end
+end
+```
+
+## Newline after block
+
+```ruby
+# bad
+def method
+ if issue.save
+ issue.send_email
+ end
+ render json: issue
+end
+```
+
+```ruby
+# good
+def method
+ if issue.save
+ issue.send_email
+ end
+
+ render json: issue
+end
+```
+
+### Exception: no need for newline when code block starts or ends right inside another code block
+
+```ruby
+# bad
+def method
+
+ if issue
+
+ if issue.valid?
+ issue.save
+ end
+
+ end
+
+end
+```
+
+```ruby
+# good
+def method
+ if issue
+ if issue.valid?
+ issue.save
+ end
+ end
+end
+```
diff --git a/doc/development/rake_tasks.md b/doc/development/rake_tasks.md
index 8852dbcb19e..a7175f3f87e 100644
--- a/doc/development/rake_tasks.md
+++ b/doc/development/rake_tasks.md
@@ -14,11 +14,33 @@ Note: `db:setup` calls `db:seed` but this does nothing.
## Run tests
-This runs all test suites present in GitLab.
+In order to run the test you can use the following commands:
+- `rake spinach` to run the spinach suite
+- `rake spec` to run the rspec suite
+- `rake teaspoon` to run the teaspoon test suite
+- `rake gitlab:test` to run all the tests
-```
-bundle exec rake test
-```
+Note: Both `rake spinach` and `rake spec` takes significant time to pass.
+Instead of running full test suite locally you can save a lot of time by running
+a single test or directory related to your changes. After you submit merge request
+CI will run full test suite for you. Green CI status in the merge request means
+full test suite is passed.
+
+Note: You can't run `rspec .` since this will try to run all the `_spec.rb`
+files it can find, also the ones in `/tmp`
+
+To run a single test file you can use:
+
+- `bundle exec rspec spec/controllers/commit_controller_spec.rb` for a rspec test
+- `bundle exec spinach features/project/issues/milestones.feature` for a spinach test
+
+To run several tests inside one directory:
+
+- `bundle exec rspec spec/requests/api/` for the rspec tests if you want to test API only
+- `bundle exec spinach features/profile/` for the spinach tests if you want to test only profile pages
+
+If you want to use [Spring](https://github.com/rails/spring) set
+`ENABLE_SPRING=1` in your environment.
## Generate searchable docs for source code
diff --git a/doc/development/what_requires_downtime.md b/doc/development/what_requires_downtime.md
new file mode 100644
index 00000000000..abd693cf72d
--- /dev/null
+++ b/doc/development/what_requires_downtime.md
@@ -0,0 +1,153 @@
+# What requires downtime?
+
+When working with a database certain operations can be performed without taking
+GitLab offline, others do require a downtime period. This guide describes
+various operations and their impact.
+
+## Adding Columns
+
+On PostgreSQL you can safely add a new column to an existing table as long as it
+does **not** have a default value. For example, this query would not require
+downtime:
+
+```sql
+ALTER TABLE projects ADD COLUMN random_value int;
+```
+
+Add a column _with_ a default however does require downtime. For example,
+consider this query:
+
+```sql
+ALTER TABLE projects ADD COLUMN random_value int DEFAULT 42;
+```
+
+This requires updating every single row in the `projects` table so that
+`random_value` is set to `42` by default. This requires updating all rows and
+indexes in a table. This in turn acquires enough locks on the table for it to
+effectively block any other queries.
+
+As of MySQL 5.6 adding a column to a table is still quite an expensive
+operation, even when using `ALGORITHM=INPLACE` and `LOCK=NONE`. This means
+downtime _may_ be required when modifying large tables as otherwise the
+operation could potentially take hours to complete.
+
+## Dropping Columns
+
+On PostgreSQL you can safely remove an existing column without the need for
+downtime. When you drop a column in PostgreSQL it's not immediately removed,
+instead it is simply disabled. The data is removed on the next vacuum run.
+
+On MySQL this operation requires downtime.
+
+While database wise dropping a column may be fine on PostgreSQL this operation
+still requires downtime because the application code may still be using the
+column that was removed. For example, consider the following migration:
+
+```ruby
+class MyMigration < ActiveRecord::Migration
+ def change
+ remove_column :projects, :dummy
+ end
+end
+```
+
+Now imagine that the GitLab instance is running and actively uses the `dummy`
+column. If we were to run the migration this would result in the GitLab instance
+producing errors whenever it tries to use the `dummy` column.
+
+As a result of the above downtime _is_ required when removing a column, even
+when using PostgreSQL.
+
+## Changing Column Constraints
+
+Generally changing column constraints requires checking all rows in the table to
+see if they meet the new constraint, unless a constraint is _removed_. For
+example, changing a column that previously allowed NULL values to not allow NULL
+values requires the database to verify all existing rows.
+
+The specific behaviour varies a bit between databases but in general the safest
+approach is to assume changing constraints requires downtime.
+
+## Changing Column Types
+
+This operation requires downtime.
+
+## Adding Indexes
+
+Adding indexes is an expensive process that blocks INSERT and UPDATE queries for
+the duration. When using PostgreSQL one can work arounds this by using the
+`CONCURRENTLY` option:
+
+```sql
+CREATE INDEX CONCURRENTLY index_name ON projects (column_name);
+```
+
+Migrations can take advantage of this by using the method
+`add_concurrent_index`. For example:
+
+```ruby
+class MyMigration < ActiveRecord::Migration
+ def change
+ add_concurrent_index :projects, :column_name
+ end
+end
+```
+
+When running this on PostgreSQL the `CONCURRENTLY` option mentioned above is
+used. On MySQL this method produces a regular `CREATE INDEX` query.
+
+MySQL doesn't really have a workaround for this. Supposedly it _can_ create
+indexes without the need for downtime but only for variable width columns. The
+details on this are a bit sketchy. Since it's better to be safe than sorry one
+should assume that adding indexes requires downtime on MySQL.
+
+## Dropping Indexes
+
+Dropping an index does not require downtime on both PostgreSQL and MySQL.
+
+## Adding Tables
+
+This operation is safe as there's no code using the table just yet.
+
+## Dropping Tables
+
+This operation requires downtime as application code may still be using the
+table.
+
+## Adding Foreign Keys
+
+Adding foreign keys acquires an exclusive lock on both the source and target
+tables in PostgreSQL. This requires downtime as otherwise the entire application
+grinds to a halt for the duration of the operation.
+
+On MySQL this operation also requires downtime _unless_ foreign key checks are
+disabled. Because this means checks aren't enforced this is not ideal, as such
+one should assume MySQL also requires downtime.
+
+## Removing Foreign Keys
+
+This operation should not require downtime on both PostgreSQL and MySQL.
+
+## Updating Data
+
+Updating data should generally be safe. The exception to this is data that's
+being migrated from one version to another while the application still produces
+data in the old version.
+
+For example, imagine the application writes the string `'dog'` to a column but
+it really is meant to write `'cat'` instead. One might think that the following
+migration is all that is needed to solve this problem:
+
+```ruby
+class MyMigration < ActiveRecord::Migration
+ def up
+ execute("UPDATE some_table SET column = 'cat' WHERE column = 'dog';")
+ end
+end
+```
+
+Unfortunately this is not enough. Because the application is still running and
+using the old value this may result in the table still containing rows where
+`column` is set to `dog`, even after the migration finished.
+
+In these cases downtime _is_ required, even for rarely updated tables.
diff --git a/doc/monitoring/health_check.md b/doc/monitoring/health_check.md
index 0d17799372f..70326f1ff80 100644
--- a/doc/monitoring/health_check.md
+++ b/doc/monitoring/health_check.md
@@ -1,6 +1,6 @@
# Health Check
->**Note:** This feature was [introduced][ce-3888] in GitLab 8.8.
+> [Introduced][ce-3888] in GitLab 8.8.
GitLab provides a health check endpoint for uptime monitoring on the `health_check` web
endpoint. The health check reports on the overall system status based on the status of
diff --git a/doc/user/admin_area/settings/continuous_integration.md b/doc/user/admin_area/settings/continuous_integration.md
new file mode 100644
index 00000000000..34e2e557f89
--- /dev/null
+++ b/doc/user/admin_area/settings/continuous_integration.md
@@ -0,0 +1,20 @@
+# Continuous integration Admin settings
+
+## Maximum artifacts size
+
+The maximum size of the [build artifacts][art-yml] can be set in the Admin area
+of your GitLab instance. The value is in MB and the default is 100MB. Note that
+this setting is set for each build.
+
+1. Go to **Admin area > Settings** (`/admin/application_settings`).
+
+ ![Admin area settings button](img/admin_area_settings_button.png)
+
+1. Change the value of the maximum artifacts size (in MB):
+
+ ![Admin area maximum artifacts size](img/admin_area_maximum_artifacts_size.png)
+
+1. Hit **Save** for the changes to take effect.
+
+
+[art-yml]: ../../../administration/build_artifacts.md
diff --git a/doc/user/admin_area/settings/img/admin_area_maximum_artifacts_size.png b/doc/user/admin_area/settings/img/admin_area_maximum_artifacts_size.png
new file mode 100644
index 00000000000..53f7e76033e
--- /dev/null
+++ b/doc/user/admin_area/settings/img/admin_area_maximum_artifacts_size.png
Binary files differ
diff --git a/doc/user/admin_area/settings/img/admin_area_settings_button.png b/doc/user/admin_area/settings/img/admin_area_settings_button.png
new file mode 100644
index 00000000000..509708b627f
--- /dev/null
+++ b/doc/user/admin_area/settings/img/admin_area_settings_button.png
Binary files differ
diff --git a/doc/user/project/builds/artifacts.md b/doc/user/project/builds/artifacts.md
new file mode 100644
index 00000000000..c93ae1c369c
--- /dev/null
+++ b/doc/user/project/builds/artifacts.md
@@ -0,0 +1,104 @@
+# Introduction to build artifacts
+
+>**Notes:**
+>- Since GitLab 8.2 and GitLab Runner 0.7.0, build artifacts that are created by
+ GitLab Runner are uploaded to GitLab and are downloadable as a single archive
+ (`tar.gz`) using the GitLab UI.
+>- Starting from GitLab 8.4 and GitLab Runner 1.0, the artifacts archive format
+ changed to `ZIP`, and it is now possible to browse its contents, with the added
+ ability of downloading the files separately.
+>- The artifacts browser will be available only for new artifacts that are sent
+ to GitLab using GitLab Runner version 1.0 and up. It will not be possible to
+ browse old artifacts already uploaded to GitLab.
+>- This is the user documentation. For the administration guide see
+ [administration/build_artifacts.md](../../../administration/build_artifacts.md).
+
+Artifacts is a list of files and directories which are attached to a build
+after it completes successfully. This feature is enabled by default in all GitLab installations.
+
+## Defining artifacts in `.gitlab-ci.yml`
+
+A simple example of using the artifacts definition in `.gitlab-ci.yml` would be
+the following:
+
+```yaml
+pdf:
+ script: xelatex mycv.tex
+ artifacts:
+ paths:
+ - mycv.pdf
+```
+
+A job named `pdf` calls the `xelatex` command in order to build a pdf file from
+the latex source file `mycv.tex`. We then define the `artifacts` paths which in
+turn are defined with the `paths` keyword. All paths to files and directories
+are relative to the repository that was cloned during the build.
+
+For more examples on artifacts, follow the artifacts reference in
+[`.gitlab-ci.yml` documentation](../../../ci/yaml/README.md#artifacts).
+
+## Browsing build artifacts
+
+When GitLab receives an artifacts archive, an archive metadata file is also
+generated. This metadata file describes all the entries that are located in the
+artifacts archive itself. The metadata file is in a binary format, with
+additional GZIP compression.
+
+GitLab does not extract the artifacts archive in order to save space, memory
+and disk I/O. It instead inspects the metadata file which contains all the
+relevant information. This is especially important when there is a lot of
+artifacts, or an archive is a very large file.
+
+---
+
+After a build finishes, if you visit the build's specific page, you can see
+that there are two buttons. One is for downloading the artifacts archive and
+the other for browsing its contents.
+
+![Build artifacts browser button](img/build_artifacts_browser_button.png)
+
+---
+
+The archive browser shows the name and the actual file size of each file in the
+archive. If your artifacts contained directories, then you are also able to
+browse inside them.
+
+Below you can see how browsing looks like. In this case we have browsed inside
+the archive and at this point there is one directory and one HTML file.
+
+![Build artifacts browser](img/build_artifacts_browser.png)
+
+---
+
+## Downloading build artifacts
+
+>**Note:**
+GitLab does not extract the entire artifacts archive to send just a single file
+to the user. When clicking on a specific file, [GitLab Workhorse] extracts it
+from the archive and the download begins. This implementation saves space,
+memory and disk I/O.
+
+If you need to download the whole archive, there are buttons in various places
+inside GitLab that make that possible.
+
+1. While on the pipelines page, you can see the download icon for each build's
+ artifacts archive in the right corner:
+
+ ![Build artifacts in Pipelines page](img/build_artifacts_pipelines_page.png)
+
+1. While on the builds page, you can see the download icon for each build's
+ artifacts archive in the right corner:
+
+ ![Build artifacts in Builds page](img/build_artifacts_builds_page.png)
+
+1. While inside a specific build, you are presented with a download button
+ along with the one that browses the archive:
+
+ ![Build artifacts browser button](img/build_artifacts_browser_button.png)
+
+1. And finally, when browsing an archive you can see the download button at
+ the top right corner:
+
+ ![Build artifacts browser](img/build_artifacts_browser.png)
+
+[gitlab workhorse]: https://gitlab.com/gitlab-org/gitlab-workhorse "GitLab Workhorse repository"
diff --git a/doc/user/project/builds/img/build_artifacts_browser.png b/doc/user/project/builds/img/build_artifacts_browser.png
new file mode 100644
index 00000000000..d95e2800c0f
--- /dev/null
+++ b/doc/user/project/builds/img/build_artifacts_browser.png
Binary files differ
diff --git a/doc/user/project/builds/img/build_artifacts_browser_button.png b/doc/user/project/builds/img/build_artifacts_browser_button.png
new file mode 100644
index 00000000000..463540634e3
--- /dev/null
+++ b/doc/user/project/builds/img/build_artifacts_browser_button.png
Binary files differ
diff --git a/doc/user/project/builds/img/build_artifacts_builds_page.png b/doc/user/project/builds/img/build_artifacts_builds_page.png
new file mode 100644
index 00000000000..db78386ba7b
--- /dev/null
+++ b/doc/user/project/builds/img/build_artifacts_builds_page.png
Binary files differ
diff --git a/doc/user/project/builds/img/build_artifacts_pipelines_page.png b/doc/user/project/builds/img/build_artifacts_pipelines_page.png
new file mode 100644
index 00000000000..6c2d1a4bdc7
--- /dev/null
+++ b/doc/user/project/builds/img/build_artifacts_pipelines_page.png
Binary files differ
diff --git a/doc/user/project/labels.md b/doc/user/project/labels.md
index 4258185b7d0..1259a16330b 100644
--- a/doc/user/project/labels.md
+++ b/doc/user/project/labels.md
@@ -46,10 +46,11 @@ When you are ready press the **Create label** button to create the new label.
## Prioritize labels
>**Notes:**
- - This feature was introduced in GitLab 8.9.
- - Priority sorting is based on the highest priority label only. This might
- change in the future, follow the discussion in
- https://gitlab.com/gitlab-org/gitlab-ce/issues/18554.
+>
+> - Introduced in GitLab 8.9.
+> - Priority sorting is based on the highest priority label only. This might
+> change in the future, follow the discussion in
+> https://gitlab.com/gitlab-org/gitlab-ce/issues/18554.
Prioritized labels are like any other label, but sorted by priority. This allows
you to sort issues and merge requests by priority.
@@ -87,8 +88,7 @@ important.
## Create a new label right from the issue tracker
->**Note:**
-This feature was introduced in GitLab 8.6.
+> Introduced in GitLab 8.6.
There are times when you are already in the issue tracker searching for a
label, only to realize it doesn't exist. Instead of going to the **Labels**
diff --git a/doc/user/project/protected_branches.md b/doc/user/project/protected_branches.md
index 6a8170b5ecb..96d9bdc1b29 100644
--- a/doc/user/project/protected_branches.md
+++ b/doc/user/project/protected_branches.md
@@ -47,8 +47,7 @@ creation.
## Wildcard protected branches
->**Note:**
-This feature was [introduced][ce-4665] in GitLab 8.10.
+> [Introduced][ce-4665] in GitLab 8.10.
You can specify a wildcard protected branch, which will protect all branches
matching the wildcard. For example:
diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md
index 38e9786123d..2513def49a4 100644
--- a/doc/user/project/settings/import_export.md
+++ b/doc/user/project/settings/import_export.md
@@ -1,18 +1,19 @@
# Project import/export
>**Notes:**
- - This feature was [introduced][ce-3050] in GitLab 8.9
- - Importing will not be possible if the import instance version is lower
- than that of the exporter.
- - For existing installations, the project import option has to be enabled in
- application settings (`/admin/application_settings`) under 'Import sources'.
- Ask your administrator if you don't see the **GitLab export** button when
- creating a new project.
- - You can find some useful raketasks if you are an administrator in the
- [import_export](../../../administration/raketasks/project_import_export.md)
- raketask.
- - The exports are stored in a temporary [shared directory][tmp] and are deleted
- every 24 hours by a specific worker.
+>
+> - [Introduced][ce-3050] in GitLab 8.9.
+> - Importing will not be possible if the import instance version is lower
+> than that of the exporter.
+> - For existing installations, the project import option has to be enabled in
+> application settings (`/admin/application_settings`) under 'Import sources'.
+> Ask your administrator if you don't see the **GitLab export** button when
+> creating a new project.
+> - You can find some useful raketasks if you are an administrator in the
+> [import_export](../../../administration/raketasks/project_import_export.md)
+> raketask.
+> - The exports are stored in a temporary [shared directory][tmp] and are deleted
+> every 24 hours by a specific worker.
Existing projects running on any GitLab instance or GitLab.com can be exported
with all their related data and be moved into a new GitLab instance.
diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md
index 8559b67af04..d4b28d875cd 100644
--- a/doc/web_hooks/web_hooks.md
+++ b/doc/web_hooks/web_hooks.md
@@ -26,6 +26,10 @@ GitLab webhooks keep in mind the following things:
you are writing a low-level hook this is important to remember.
- GitLab ignores the HTTP status code returned by your endpoint.
+## Secret Token
+
+If you specify a secret token, it will be sent with the hook request in the `X-Gitlab-Token` HTTP header. Your webhook endpoint can check that to verify that the request is legitimate.
+
## SSL Verification
By default, the SSL certificate of the webhook endpoint is verified based on
diff --git a/doc/workflow/award_emoji.md b/doc/workflow/award_emoji.md
index e6f8b792707..1df0698afd0 100644
--- a/doc/workflow/award_emoji.md
+++ b/doc/workflow/award_emoji.md
@@ -1,7 +1,7 @@
# Award emoji
>**Note:**
-This feature was [introduced][1825] in GitLab 8.2.
+[Introduced][1825] in GitLab 8.2.
When you're collaborating online, you get fewer opportunities for high-fives
and thumbs-ups. Emoji can be awarded to issues and merge requests, making
@@ -16,7 +16,7 @@ award emoji.
## Sort issues and merge requests on vote count
>**Note:**
-This feature was [introduced][2871] in GitLab 8.5.
+[Introduced][2871] in GitLab 8.5.
You can quickly sort issues and merge requests by the number of votes they
have received. The sort options can be found in the dropdown menu as "Most
@@ -45,7 +45,7 @@ downvotes.
## Award emoji for comments
>**Note:**
-This feature was [introduced][4291] in GitLab 8.9.
+[Introduced][4291] in GitLab 8.9.
Award emoji can also be applied to individual comments when you want to
celebrate an accomplishment or agree with an opinion.
diff --git a/doc/workflow/cherry_pick_changes.md b/doc/workflow/cherry_pick_changes.md
index 4a499009842..64b94d81024 100644
--- a/doc/workflow/cherry_pick_changes.md
+++ b/doc/workflow/cherry_pick_changes.md
@@ -1,7 +1,6 @@
# Cherry-pick changes
->**Note:**
-This feature was [introduced][ce-3514] in GitLab 8.7.
+> [Introduced][ce-3514] in GitLab 8.7.
---
diff --git a/doc/workflow/file_finder.md b/doc/workflow/file_finder.md
index b69ae663272..8d87b030c83 100644
--- a/doc/workflow/file_finder.md
+++ b/doc/workflow/file_finder.md
@@ -1,6 +1,6 @@
# File finder
-_**Note:** This feature was [introduced][gh-9889] in GitLab 8.4._
+> [Introduced][gh-9889] in GitLab 8.4.
---
diff --git a/doc/workflow/revert_changes.md b/doc/workflow/revert_changes.md
index 399366b0cdc..5ead9f4177f 100644
--- a/doc/workflow/revert_changes.md
+++ b/doc/workflow/revert_changes.md
@@ -1,6 +1,6 @@
# Reverting changes
-_**Note:** This feature was [introduced][ce-1990] in GitLab 8.5._
+> [Introduced][ce-1990] in GitLab 8.5.
---
diff --git a/doc/workflow/todos.md b/doc/workflow/todos.md
index 9524ffd5420..a50ba305deb 100644
--- a/doc/workflow/todos.md
+++ b/doc/workflow/todos.md
@@ -1,6 +1,6 @@
# GitLab Todos
->**Note:** This feature was [introduced][ce-2817] in GitLab 8.5.
+> [Introduced][ce-2817] in GitLab 8.5.
When you log into GitLab, you normally want to see where you should spend your
time and take some action, or what you need to keep an eye on. All without the
diff --git a/doc/workflow/web_editor.md b/doc/workflow/web_editor.md
index 1832567a34c..ee8e7862572 100644
--- a/doc/workflow/web_editor.md
+++ b/doc/workflow/web_editor.md
@@ -70,8 +70,7 @@ There are multiple ways to create a branch from GitLab's web interface.
### Create a new branch from an issue
->**Note:**
-This feature was [introduced][ce-2808] in GitLab 8.6.
+> [Introduced][ce-2808] in GitLab 8.6.
In case your development workflow dictates to have an issue for every merge
request, you can quickly create a branch right on the issue page which will be
diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature
index 21768c15c17..6bac6011467 100644
--- a/features/project/merge_requests.feature
+++ b/features/project/merge_requests.feature
@@ -237,6 +237,15 @@ Feature: Project Merge Requests
Then I should see additional file lines
@javascript
+ Scenario: I unfold diff in Side-by-Side view
+ Given project "Shop" have "Bug NS-05" open merge request with diffs inside
+ And I visit merge request page "Bug NS-05"
+ And I click on the Changes tab
+ And I click Side-by-side Diff tab
+ And I unfold diff
+ Then I should see additional file lines
+
+ @javascript
Scenario: I show comments on a merge request side-by-side diff with comments in multiple files
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
diff --git a/features/steps/project/merge_requests.rb b/features/steps/project/merge_requests.rb
index da848afd48e..a02a54923a5 100644
--- a/features/steps/project/merge_requests.rb
+++ b/features/steps/project/merge_requests.rb
@@ -477,6 +477,9 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I click Side-by-side Diff tab' do
find('a', text: 'Side-by-side').trigger('click')
+
+ # Waits for load
+ expect(page).to have_css('.parallel')
end
step 'I should see comments on the side-by-side diff page' do
diff --git a/lib/api/api.rb b/lib/api/api.rb
index bd16806892b..6cd4a853dbe 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -7,8 +7,10 @@ module API
rack_response({ 'message' => '404 Not found' }.to_json, 404)
end
- rescue_from Grape::Exceptions::ValidationErrors do |e|
- error!({ messages: e.full_messages }, 400)
+ # Retain 405 error rather than a 500 error for Grape 0.15.0+.
+ # See: https://github.com/ruby-grape/grape/commit/252bfd27c320466ec3c0751812cf44245e97e5de
+ rescue_from Grape::Exceptions::Base do |e|
+ error! e.message, e.status, e.headers
end
rescue_from :all do |exception|
diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb
index 5c570b5e5ca..825e05fbae3 100644
--- a/lib/api/deploy_keys.rb
+++ b/lib/api/deploy_keys.rb
@@ -10,6 +10,9 @@ module API
present keys, with: Entities::SSHKey
end
+ params do
+ requires :id, type: String, desc: 'The ID of the project'
+ end
resource :projects do
before { authorize_admin_project }
@@ -17,52 +20,43 @@ module API
# Use "projects/:id/deploy_keys/..." instead.
#
%w(keys deploy_keys).each do |path|
- # Get a specific project's deploy keys
- #
- # Example Request:
- # GET /projects/:id/deploy_keys
+ desc "Get a specific project's deploy keys" do
+ success Entities::SSHKey
+ end
get ":id/#{path}" do
present user_project.deploy_keys, with: Entities::SSHKey
end
- # Get single deploy key owned by currently authenticated user
- #
- # Example Request:
- # GET /projects/:id/deploy_keys/:key_id
+ desc 'Get single deploy key' do
+ success Entities::SSHKey
+ end
+ params do
+ requires :key_id, type: Integer, desc: 'The ID of the deploy key'
+ end
get ":id/#{path}/:key_id" do
key = user_project.deploy_keys.find params[:key_id]
present key, with: Entities::SSHKey
end
- # Add new deploy key to currently authenticated user
- # If deploy key already exists - it will be joined to project
- # but only if original one was accessible by same user
- #
- # Parameters:
- # key (required) - New deploy Key
- # title (required) - New deploy Key's title
- # Example Request:
- # POST /projects/:id/deploy_keys
+ # TODO: for 9.0 we should check if params are there with the params block
+ # grape provides, at this point we'd change behaviour so we can't
+ # Behaviour now if you don't provide all required params: it renders a
+ # validation error or two.
+ desc 'Add new deploy key to currently authenticated user' do
+ success Entities::SSHKey
+ end
post ":id/#{path}" do
attrs = attributes_for_keys [:title, :key]
+ attrs[:key].strip! if attrs[:key]
- if attrs[:key].present?
- attrs[:key].strip!
-
- # check if key already exist in project
- key = user_project.deploy_keys.find_by(key: attrs[:key])
- if key
- present key, with: Entities::SSHKey
- next
- end
+ key = user_project.deploy_keys.find_by(key: attrs[:key])
+ present key, with: Entities::SSHKey if key
- # Check for available deploy keys in other projects
- key = current_user.accessible_deploy_keys.find_by(key: attrs[:key])
- if key
- user_project.deploy_keys << key
- present key, with: Entities::SSHKey
- next
- end
+ # Check for available deploy keys in other projects
+ key = current_user.accessible_deploy_keys.find_by(key: attrs[:key])
+ if key
+ user_project.deploy_keys << key
+ present key, with: Entities::SSHKey
end
key = DeployKey.new attrs
@@ -74,12 +68,46 @@ module API
end
end
- # Delete existing deploy key of currently authenticated user
- #
- # Example Request:
- # DELETE /projects/:id/deploy_keys/:key_id
+ desc 'Enable a deploy key for a project' do
+ detail 'This feature was added in GitLab 8.11'
+ success Entities::SSHKey
+ end
+ params do
+ requires :key_id, type: Integer, desc: 'The ID of the deploy key'
+ end
+ post ":id/#{path}/:key_id/enable" do
+ key = ::Projects::EnableDeployKeyService.new(user_project,
+ current_user, declared(params)).execute
+
+ if key
+ present key, with: Entities::SSHKey
+ else
+ not_found!('Deploy Key')
+ end
+ end
+
+ desc 'Disable a deploy key for a project' do
+ detail 'This feature was added in GitLab 8.11'
+ success Entities::SSHKey
+ end
+ params do
+ requires :key_id, type: Integer, desc: 'The ID of the deploy key'
+ end
+ delete ":id/#{path}/:key_id/disable" do
+ key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id])
+ key.destroy
+
+ present key.deploy_key, with: Entities::SSHKey
+ end
+
+ desc 'Delete existing deploy key of currently authenticated user' do
+ success Key
+ end
+ params do
+ requires :key_id, type: Integer, desc: 'The ID of the deploy key'
+ end
delete ":id/#{path}/:key_id" do
- key = user_project.deploy_keys.find params[:key_id]
+ key = user_project.deploy_keys.find(params[:key_id])
key.destroy
end
end
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index 5b73fc8fcee..46762d401fb 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -35,6 +35,7 @@ module Banzai
def process_link_attr(html_attr)
return if html_attr.blank?
+ return if html_attr.value.start_with?('//')
uri = URI(html_attr.value)
if uri.relative? && uri.path.present?
@@ -92,7 +93,7 @@ module Banzai
parts = request_path.split('/')
parts.pop if uri_type(request_path) != :tree
- path.sub!(%r{^\./}, '')
+ path.sub!(%r{\A\./}, '')
while path.start_with?('../')
parts.pop
diff --git a/lib/banzai/filter/video_link_filter.rb b/lib/banzai/filter/video_link_filter.rb
index fd8b9a6f0cc..ac7bbcb0d10 100644
--- a/lib/banzai/filter/video_link_filter.rb
+++ b/lib/banzai/filter/video_link_filter.rb
@@ -1,11 +1,9 @@
module Banzai
module Filter
-
# Find every image that isn't already wrapped in an `a` tag, and that has
# a `src` attribute ending with a video extension, add a new video node and
# a "Download" link in the case the video cannot be played.
class VideoLinkFilter < HTML::Pipeline::Filter
-
def call
doc.xpath(query).each do |el|
el.replace(video_node(doc, el))
@@ -54,6 +52,5 @@ module Banzai
container
end
end
-
end
end
diff --git a/lib/ci/static_model.rb b/lib/ci/static_model.rb
deleted file mode 100644
index bb2bdbed495..00000000000
--- a/lib/ci/static_model.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# Provides an ActiveRecord-like interface to a model whose data is not persisted to a database.
-module Ci
- module StaticModel
- extend ActiveSupport::Concern
-
- module ClassMethods
- # Used by ActiveRecord's polymorphic association to set object_id
- def primary_key
- 'id'
- end
-
- # Used by ActiveRecord's polymorphic association to set object_type
- def base_class
- self
- end
- end
-
- # Used by AR for fetching attributes
- #
- # Pass it along if we respond to it.
- def [](key)
- send(key) if respond_to?(key)
- end
-
- def to_param
- id
- end
-
- def new_record?
- false
- end
-
- def persisted?
- false
- end
-
- def destroyed?
- false
- end
-
- def ==(other)
- if other.is_a? ::Ci::StaticModel
- id == other.id
- else
- super
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/config/node/validatable.rb b/lib/gitlab/ci/config/node/validatable.rb
index f6e2896dfb2..085e6e988d1 100644
--- a/lib/gitlab/ci/config/node/validatable.rb
+++ b/lib/gitlab/ci/config/node/validatable.rb
@@ -7,13 +7,11 @@ module Gitlab
class_methods do
def validator
- validator = Class.new(Node::Validator)
-
- if defined?(@validations)
- @validations.each { |rules| validator.class_eval(&rules) }
+ @validator ||= Class.new(Node::Validator).tap do |validator|
+ if defined?(@validations)
+ @validations.each { |rules| validator.class_eval(&rules) }
+ end
end
-
- validator
end
private
diff --git a/lib/gitlab/closing_issue_extractor.rb b/lib/gitlab/closing_issue_extractor.rb
index 9bef9037ad6..58f86abc5c4 100644
--- a/lib/gitlab/closing_issue_extractor.rb
+++ b/lib/gitlab/closing_issue_extractor.rb
@@ -22,7 +22,9 @@ module Gitlab
@extractor.analyze(closing_statements.join(" "))
- @extractor.issues
+ @extractor.issues.reject do |issue|
+ @extractor.project.forked_from?(issue.project) # Don't extract issues on original project
+ end
end
end
end
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 8e8f39d9cb2..69943e22353 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -14,7 +14,7 @@ module Gitlab
@user_access = UserAccess.new(user, project: project)
end
- def check(cmd, changes = nil)
+ def check(cmd, changes)
return build_status_object(false, "Git access over #{protocol.upcase} is not allowed") unless protocol_allowed?
unless actor
diff --git a/lib/gitlab/git_post_receive.rb b/lib/gitlab/git_post_receive.rb
index a088e19d1e7..d32bdd86427 100644
--- a/lib/gitlab/git_post_receive.rb
+++ b/lib/gitlab/git_post_receive.rb
@@ -39,7 +39,6 @@ module Gitlab
end
def deserialize_changes(changes)
- changes = Base64.decode64(changes) unless changes.include?(' ')
changes = utf8_encode_changes(changes)
changes.lines
end
diff --git a/lib/gitlab/import_export/avatar_restorer.rb b/lib/gitlab/import_export/avatar_restorer.rb
index 352539eb594..cfa595629f4 100644
--- a/lib/gitlab/import_export/avatar_restorer.rb
+++ b/lib/gitlab/import_export/avatar_restorer.rb
@@ -1,7 +1,6 @@
module Gitlab
module ImportExport
class AvatarRestorer
-
def initialize(project:, shared:)
@project = project
@shared = shared
diff --git a/lib/gitlab/import_export/members_mapper.rb b/lib/gitlab/import_export/members_mapper.rb
index b459054c198..36c4cf6efa0 100644
--- a/lib/gitlab/import_export/members_mapper.rb
+++ b/lib/gitlab/import_export/members_mapper.rb
@@ -18,11 +18,14 @@ module Gitlab
@map ||=
begin
@exported_members.inject(missing_keys_tracking_hash) do |hash, member|
- existing_user = User.where(find_project_user_query(member)).first
- old_user_id = member['user']['id']
- if existing_user && add_user_as_team_member(existing_user, member)
- hash[old_user_id] = existing_user.id
+ if member['user']
+ old_user_id = member['user']['id']
+ existing_user = User.where(find_project_user_query(member)).first
+ hash[old_user_id] = existing_user.id if existing_user && add_team_member(member, existing_user)
+ else
+ add_team_member(member)
end
+
hash
end
end
@@ -45,7 +48,7 @@ module Gitlab
ProjectMember.create!(user: @user, access_level: ProjectMember::MASTER, source_id: @project.id, importing: true)
end
- def add_user_as_team_member(existing_user, member)
+ def add_team_member(member, existing_user = nil)
member['user'] = existing_user
ProjectMember.create(member_hash(member)).persisted?
diff --git a/lib/gitlab/ldap/access.rb b/lib/gitlab/ldap/access.rb
index f2b649e50a2..2f326d00a2f 100644
--- a/lib/gitlab/ldap/access.rb
+++ b/lib/gitlab/ldap/access.rb
@@ -25,7 +25,7 @@ module Gitlab
end
end
- def initialize(user, adapter=nil)
+ def initialize(user, adapter = nil)
@adapter = adapter
@user = user
@provider = user.ldap_identity.provider
diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb
index df65179bfea..9a5bcfb5c9b 100644
--- a/lib/gitlab/ldap/adapter.rb
+++ b/lib/gitlab/ldap/adapter.rb
@@ -13,7 +13,7 @@ module Gitlab
Gitlab::LDAP::Config.new(provider)
end
- def initialize(provider, ldap=nil)
+ def initialize(provider, ldap = nil)
@provider = provider
@ldap = ldap || Net::LDAP.new(config.adapter_options)
end
diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb
index 43e07e09160..ca23ccef25b 100644
--- a/lib/gitlab/popen.rb
+++ b/lib/gitlab/popen.rb
@@ -5,7 +5,7 @@ module Gitlab
module Popen
extend self
- def popen(cmd, path=nil)
+ def popen(cmd, path = nil)
unless cmd.is_a?(Array)
raise "System commands must be given as an array of strings"
end
diff --git a/lib/gitlab/redis.rb b/lib/gitlab/redis.rb
index 40766f35f77..1f92986ec9a 100644
--- a/lib/gitlab/redis.rb
+++ b/lib/gitlab/redis.rb
@@ -37,7 +37,7 @@ module Gitlab
redis_config_hash
end
- def initialize(rails_env=nil)
+ def initialize(rails_env = nil)
rails_env ||= Rails.env
config_file = File.expand_path('../../../config/resque.yml', __FILE__)
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 3a69027368f..c55a7fc4d3d 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -30,6 +30,8 @@ module Gitlab
return false unless user
if project.protected_branch?(ref)
+ return true if project.empty_repo? && project.user_can_push_to_empty_repo?(user)
+
access_levels = project.protected_branches.matching(ref).map(&:push_access_level)
access_levels.any? { |access_level| access_level.check_access(user) }
else
diff --git a/lib/support/nginx/gitlab b/lib/support/nginx/gitlab
index 4a4892a2e07..d521de28e8a 100644
--- a/lib/support/nginx/gitlab
+++ b/lib/support/nginx/gitlab
@@ -49,12 +49,7 @@ server {
proxy_http_version 1.1;
- ## By overwriting Host and clearing X-Forwarded-Host we ensure that
- ## internal HTTP redirects generated by GitLab always send users to
- ## YOUR_SERVER_FQDN.
- proxy_set_header Host YOUR_SERVER_FQDN;
- proxy_set_header X-Forwarded-Host "";
-
+ proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
diff --git a/lib/support/nginx/gitlab-ssl b/lib/support/nginx/gitlab-ssl
index 0b93d7f292f..bf014b56cf6 100644
--- a/lib/support/nginx/gitlab-ssl
+++ b/lib/support/nginx/gitlab-ssl
@@ -93,12 +93,7 @@ server {
proxy_http_version 1.1;
- ## By overwriting Host and clearing X-Forwarded-Host we ensure that
- ## internal HTTP redirects generated by GitLab always send users to
- ## YOUR_SERVER_FQDN.
- proxy_set_header Host YOUR_SERVER_FQDN;
- proxy_set_header X-Forwarded-Host "";
-
+ proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
diff --git a/lib/tasks/gitlab/bulk_add_permission.rake b/lib/tasks/gitlab/bulk_add_permission.rake
index 5dbf7d61e06..83dd870fa31 100644
--- a/lib/tasks/gitlab/bulk_add_permission.rake
+++ b/lib/tasks/gitlab/bulk_add_permission.rake
@@ -4,13 +4,13 @@ namespace :gitlab do
task all_users_to_all_projects: :environment do |t, args|
user_ids = User.where(admin: false).pluck(:id)
admin_ids = User.where(admin: true).pluck(:id)
- projects_ids = Project.pluck(:id)
+ project_ids = Project.pluck(:id)
- puts "Importing #{user_ids.size} users into #{projects_ids.size} projects"
- ProjectMember.add_users_into_projects(projects_ids, user_ids, ProjectMember::DEVELOPER)
+ puts "Importing #{user_ids.size} users into #{project_ids.size} projects"
+ ProjectMember.add_users_to_projects(project_ids, user_ids, ProjectMember::DEVELOPER)
- puts "Importing #{admin_ids.size} admins into #{projects_ids.size} projects"
- ProjectMember.add_users_into_projects(projects_ids, admin_ids, ProjectMember::MASTER)
+ puts "Importing #{admin_ids.size} admins into #{project_ids.size} projects"
+ ProjectMember.add_users_to_projects(project_ids, admin_ids, ProjectMember::MASTER)
end
desc "GitLab | Add a specific user to all projects (as a developer)"
@@ -18,7 +18,7 @@ namespace :gitlab do
user = User.find_by(email: args.email)
project_ids = Project.pluck(:id)
puts "Importing #{user.email} users into #{project_ids.size} projects"
- ProjectMember.add_users_into_projects(project_ids, Array.wrap(user.id), ProjectMember::DEVELOPER)
+ ProjectMember.add_users_to_projects(project_ids, Array.wrap(user.id), ProjectMember::DEVELOPER)
end
desc "GitLab | Add all users to all groups (admin users are added as owners)"
diff --git a/lib/tasks/gitlab/web_hook.rake b/lib/tasks/gitlab/web_hook.rake
index f467cc0ee29..49530e7a372 100644
--- a/lib/tasks/gitlab/web_hook.rake
+++ b/lib/tasks/gitlab/web_hook.rake
@@ -26,10 +26,10 @@ namespace :gitlab do
namespace_path = ENV['NAMESPACE']
projects = find_projects(namespace_path)
- projects_ids = projects.pluck(:id)
+ project_ids = projects.pluck(:id)
puts "Removing webhooks with the url '#{web_hook_url}' ... "
- count = WebHook.where(url: web_hook_url, project_id: projects_ids, type: 'ProjectHook').delete_all
+ count = WebHook.where(url: web_hook_url, project_id: project_ids, type: 'ProjectHook').delete_all
puts "#{count} webhooks were removed."
end
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index ab9aa65f7b9..33fe3c73822 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -39,7 +39,7 @@ describe Admin::UsersController do
user.ldap_block
end
- it 'will not unblock user' do
+ it 'does not unblock user' do
put :unblock, id: user.username
user.reload
expect(user.blocked?).to be_truthy
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 8bd210cbc3d..98e912f000c 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -5,7 +5,7 @@ describe ApplicationController do
let(:user) { create(:user) }
let(:controller) { ApplicationController.new }
- it 'should redirect if the user is over their password expiry' do
+ it 'redirects if the user is over their password expiry' do
user.password_expires_at = Time.new(2002)
expect(user.ldap_user?).to be_falsey
allow(controller).to receive(:current_user).and_return(user)
@@ -14,7 +14,7 @@ describe ApplicationController do
controller.send(:check_password_expiration)
end
- it 'should not redirect if the user is under their password expiry' do
+ it 'does not redirect if the user is under their password expiry' do
user.password_expires_at = Time.now + 20010101
expect(user.ldap_user?).to be_falsey
allow(controller).to receive(:current_user).and_return(user)
@@ -22,7 +22,7 @@ describe ApplicationController do
controller.send(:check_password_expiration)
end
- it 'should not redirect if the user is over their password expiry but they are an ldap user' do
+ it 'does not redirect if the user is over their password expiry but they are an ldap user' do
user.password_expires_at = Time.new(2002)
allow(user).to receive(:ldap_user?).and_return(true)
allow(controller).to receive(:current_user).and_return(user)
diff --git a/spec/controllers/groups/avatars_controller_spec.rb b/spec/controllers/groups/avatars_controller_spec.rb
index 91d639218e5..506aeee7d2a 100644
--- a/spec/controllers/groups/avatars_controller_spec.rb
+++ b/spec/controllers/groups/avatars_controller_spec.rb
@@ -9,7 +9,7 @@ describe Groups::AvatarsController do
sign_in(user)
end
- it 'destroy should remove avatar from DB' do
+ it 'removes avatar from DB calling destroy' do
delete :destroy, group_id: group.path
@group = assigns(:group)
expect(@group.avatar.present?).to be_falsey
diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb
index b0793cb1655..8c52f615b8b 100644
--- a/spec/controllers/groups/milestones_controller_spec.rb
+++ b/spec/controllers/groups/milestones_controller_spec.rb
@@ -15,7 +15,7 @@ describe Groups::MilestonesController do
end
describe "#create" do
- it "should create group milestone with Chinese title" do
+ it "creates group milestone with Chinese title" do
post :create,
group_id: group.id,
milestone: { project_ids: [project.id, project2.id], title: title }
diff --git a/spec/controllers/profiles/avatars_controller_spec.rb b/spec/controllers/profiles/avatars_controller_spec.rb
index ad5855df0a4..4fa0462ccdf 100644
--- a/spec/controllers/profiles/avatars_controller_spec.rb
+++ b/spec/controllers/profiles/avatars_controller_spec.rb
@@ -8,7 +8,7 @@ describe Profiles::AvatarsController do
controller.instance_variable_set(:@user, user)
end
- it 'destroy should remove avatar from DB' do
+ it 'removes avatar from DB by calling destroy' do
delete :destroy
@user = assigns(:user)
expect(@user.avatar.present?).to be_falsey
diff --git a/spec/controllers/profiles/keys_controller_spec.rb b/spec/controllers/profiles/keys_controller_spec.rb
index 3a82083717f..6bcfae0fc13 100644
--- a/spec/controllers/profiles/keys_controller_spec.rb
+++ b/spec/controllers/profiles/keys_controller_spec.rb
@@ -6,7 +6,7 @@ describe Profiles::KeysController do
describe '#new' do
before { sign_in(user) }
- it 'redirect to #index' do
+ it 'redirects to #index' do
get :new
expect(response).to redirect_to(profile_keys_path)
@@ -15,7 +15,7 @@ describe Profiles::KeysController do
describe "#get_keys" do
describe "non existant user" do
- it "should generally not work" do
+ it "does not generally work" do
get :get_keys, username: 'not-existent'
expect(response).not_to be_success
@@ -23,19 +23,19 @@ describe Profiles::KeysController do
end
describe "user with no keys" do
- it "should generally work" do
+ it "does generally work" do
get :get_keys, username: user.username
expect(response).to be_success
end
- it "should render all keys separated with a new line" do
+ it "renders all keys separated with a new line" do
get :get_keys, username: user.username
expect(response.body).to eq("")
end
- it "should respond with text/plain content type" do
+ it "responds with text/plain content type" do
get :get_keys, username: user.username
expect(response.content_type).to eq("text/plain")
end
@@ -47,13 +47,13 @@ describe Profiles::KeysController do
user.keys << create(:another_key)
end
- it "should generally work" do
+ it "does generally work" do
get :get_keys, username: user.username
expect(response).to be_success
end
- it "should render all keys separated with a new line" do
+ it "renders all keys separated with a new line" do
get :get_keys, username: user.username
expect(response.body).not_to eq("")
@@ -65,13 +65,13 @@ describe Profiles::KeysController do
expect(response.body).to match(/AQDmTillFzNTrrGgwaCKaSj/)
end
- it "should not render the comment of the key" do
+ it "does not render the comment of the key" do
get :get_keys, username: user.username
expect(response.body).not_to match(/dummy@gitlab.com/)
end
- it "should respond with text/plain content type" do
+ it "responds with text/plain content type" do
get :get_keys, username: user.username
expect(response.content_type).to eq("text/plain")
end
diff --git a/spec/controllers/projects/avatars_controller_spec.rb b/spec/controllers/projects/avatars_controller_spec.rb
index 4d724ca9ed0..f5ea097af8b 100644
--- a/spec/controllers/projects/avatars_controller_spec.rb
+++ b/spec/controllers/projects/avatars_controller_spec.rb
@@ -10,7 +10,7 @@ describe Projects::AvatarsController do
controller.instance_variable_set(:@project, project)
end
- it 'destroy should remove avatar from DB' do
+ it 'removes avatar from DB by calling destroy' do
delete :destroy, namespace_id: project.namespace.id, project_id: project.id
expect(project.avatar.present?).to be_falsey
expect(project).to be_valid
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb
index 940019b708b..7e440193d7b 100644
--- a/spec/controllers/projects/commit_controller_spec.rb
+++ b/spec/controllers/projects/commit_controller_spec.rb
@@ -47,25 +47,25 @@ describe Projects::CommitController do
end
shared_examples "export as" do |format|
- it "should generally work" do
+ it "does generally work" do
go(id: commit.id, format: format)
expect(response).to be_success
end
- it "should generate it" do
+ it "generates it" do
expect_any_instance_of(Commit).to receive(:"to_#{format}")
go(id: commit.id, format: format)
end
- it "should render it" do
+ it "renders it" do
go(id: commit.id, format: format)
expect(response.body).to eq(commit.send(:"to_#{format}"))
end
- it "should not escape Html" do
+ it "does not escape Html" do
allow_any_instance_of(Commit).to receive(:"to_#{format}").
and_return('HTML entities &<>" ')
@@ -88,7 +88,7 @@ describe Projects::CommitController do
expect(response.body).to start_with("diff --git")
end
- it "should really only be a git diff without whitespace changes" do
+ it "is only be a git diff without whitespace changes" do
go(id: '66eceea0db202bb39c4e445e8ca28689645366c5', format: format, w: 1)
expect(response.body).to start_with("diff --git")
@@ -103,13 +103,13 @@ describe Projects::CommitController do
include_examples "export as", :patch
let(:format) { :patch }
- it "should really be a git email patch" do
+ it "is a git email patch" do
go(id: commit.id, format: format)
expect(response.body).to start_with("From #{commit.id}")
end
- it "should contain a git diff" do
+ it "contains a git diff" do
go(id: commit.id, format: format)
expect(response.body).to match(/^diff --git/)
@@ -147,7 +147,7 @@ describe Projects::CommitController do
describe 'POST revert' do
context 'when target branch is not provided' do
- it 'should render the 404 page' do
+ it 'renders the 404 page' do
post(:revert,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -159,7 +159,7 @@ describe Projects::CommitController do
end
context 'when the revert was successful' do
- it 'should redirect to the commits page' do
+ it 'redirects to the commits page' do
post(:revert,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -180,7 +180,7 @@ describe Projects::CommitController do
id: commit.id)
end
- it 'should redirect to the commit page' do
+ it 'redirects to the commit page' do
# Reverting a commit that has been already reverted.
post(:revert,
namespace_id: project.namespace.to_param,
@@ -196,7 +196,7 @@ describe Projects::CommitController do
describe 'POST cherry_pick' do
context 'when target branch is not provided' do
- it 'should render the 404 page' do
+ it 'renders the 404 page' do
post(:cherry_pick,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -208,7 +208,7 @@ describe Projects::CommitController do
end
context 'when the cherry-pick was successful' do
- it 'should redirect to the commits page' do
+ it 'redirects to the commits page' do
post(:cherry_pick,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -229,7 +229,7 @@ describe Projects::CommitController do
id: master_pickable_commit.id)
end
- it 'should redirect to the commit page' do
+ it 'redirects to the commit page' do
# Cherry-picking a commit that has been already cherry-picked.
post(:cherry_pick,
namespace_id: project.namespace.to_param,
diff --git a/spec/controllers/projects/commits_controller_spec.rb b/spec/controllers/projects/commits_controller_spec.rb
index 7d8089c4bc6..2518a48e336 100644
--- a/spec/controllers/projects/commits_controller_spec.rb
+++ b/spec/controllers/projects/commits_controller_spec.rb
@@ -11,7 +11,7 @@ describe Projects::CommitsController do
describe "GET show" do
context "as atom feed" do
- it "should render as atom" do
+ it "renders as atom" do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb
index ed4cc36de58..7a57801c437 100644
--- a/spec/controllers/projects/compare_controller_spec.rb
+++ b/spec/controllers/projects/compare_controller_spec.rb
@@ -11,7 +11,7 @@ describe Projects::CompareController do
project.team << [user, :master]
end
- it 'compare should show some diffs' do
+ it 'compare shows some diffs' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -23,7 +23,7 @@ describe Projects::CompareController do
expect(assigns(:commits).length).to be >= 1
end
- it 'compare should show some diffs with ignore whitespace change option' do
+ it 'compare shows some diffs with ignore whitespace change option' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -41,7 +41,7 @@ describe Projects::CompareController do
end
describe 'non-existent refs' do
- it 'invalid source ref' do
+ it 'uses invalid source ref' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -53,7 +53,7 @@ describe Projects::CompareController do
expect(assigns(:commits)).to eq([])
end
- it 'invalid target ref' do
+ it 'uses invalid target ref' do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
diff --git a/spec/controllers/projects/forks_controller_spec.rb b/spec/controllers/projects/forks_controller_spec.rb
index f66bcb8099c..ac3469cb8a9 100644
--- a/spec/controllers/projects/forks_controller_spec.rb
+++ b/spec/controllers/projects/forks_controller_spec.rb
@@ -16,7 +16,7 @@ describe Projects::ForksController do
context 'when fork is public' do
before { forked_project.update_attribute(:visibility_level, Project::PUBLIC) }
- it 'should be visible for non logged in users' do
+ it 'is visible for non logged in users' do
get_forks
expect(assigns[:forks]).to be_present
@@ -28,7 +28,7 @@ describe Projects::ForksController do
forked_project.update_attributes(visibility_level: Project::PRIVATE, group: group)
end
- it 'should not be visible for non logged in users' do
+ it 'is not be visible for non logged in users' do
get_forks
expect(assigns[:forks]).to be_blank
@@ -38,7 +38,7 @@ describe Projects::ForksController do
before { sign_in(project.creator) }
context 'when user is not a Project member neither a group member' do
- it 'should not see the Project listed' do
+ it 'does not see the Project listed' do
get_forks
expect(assigns[:forks]).to be_blank
@@ -48,7 +48,7 @@ describe Projects::ForksController do
context 'when user is a member of the Project' do
before { forked_project.team << [project.creator, :developer] }
- it 'should see the project listed' do
+ it 'sees the project listed' do
get_forks
expect(assigns[:forks]).to be_present
@@ -58,7 +58,7 @@ describe Projects::ForksController do
context 'when user is a member of the Group' do
before { forked_project.group.add_developer(project.creator) }
- it 'should see the project listed' do
+ it 'sees the project listed' do
get_forks
expect(assigns[:forks]).to be_present
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index ec820de3d09..b6a0276846c 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -30,7 +30,7 @@ describe Projects::IssuesController do
expect(response).to have_http_status(200)
end
- it "return 301 if request path doesn't match project path" do
+ it "returns 301 if request path doesn't match project path" do
get :index, namespace_id: project.namespace.path, project_id: project.path.upcase
expect(response).to redirect_to(namespace_project_issues_path(project.namespace, project))
@@ -119,21 +119,21 @@ describe Projects::IssuesController do
let!(:request_forgery_timing_attack) { create(:issue, :confidential, project: project, assignee: assignee) }
describe 'GET #index' do
- it 'should not list confidential issues for guests' do
+ it 'does not list confidential issues for guests' do
sign_out(:user)
get_issues
expect(assigns(:issues)).to eq [issue]
end
- it 'should not list confidential issues for non project members' do
+ it 'does not list confidential issues for non project members' do
sign_in(non_member)
get_issues
expect(assigns(:issues)).to eq [issue]
end
- it 'should not list confidential issues for project members with guest role' do
+ it 'does not list confidential issues for project members with guest role' do
sign_in(member)
project.team << [member, :guest]
@@ -142,7 +142,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).to eq [issue]
end
- it 'should list confidential issues for author' do
+ it 'lists confidential issues for author' do
sign_in(author)
get_issues
@@ -150,7 +150,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).not_to include request_forgery_timing_attack
end
- it 'should list confidential issues for assignee' do
+ it 'lists confidential issues for assignee' do
sign_in(assignee)
get_issues
@@ -158,7 +158,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).to include request_forgery_timing_attack
end
- it 'should list confidential issues for project members' do
+ it 'lists confidential issues for project members' do
sign_in(member)
project.team << [member, :developer]
@@ -168,7 +168,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).to include request_forgery_timing_attack
end
- it 'should list confidential issues for admin' do
+ it 'lists confidential issues for admin' do
sign_in(admin)
get_issues
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 1f6bc84dfe8..69758494543 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -36,7 +36,7 @@ describe Projects::MergeRequestsController do
describe "GET show" do
shared_examples "export merge as" do |format|
- it "should generally work" do
+ it "does generally work" do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -46,7 +46,7 @@ describe Projects::MergeRequestsController do
expect(response).to be_success
end
- it "should generate it" do
+ it "generates it" do
expect_any_instance_of(MergeRequest).to receive(:"to_#{format}")
get(:show,
@@ -56,7 +56,7 @@ describe Projects::MergeRequestsController do
format: format)
end
- it "should render it" do
+ it "renders it" do
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
@@ -66,7 +66,7 @@ describe Projects::MergeRequestsController do
expect(response.body).to eq(merge_request.send(:"to_#{format}").to_s)
end
- it "should not escape Html" do
+ it "does not escape Html" do
allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").
and_return('HTML entities &<>" ')
@@ -118,7 +118,7 @@ describe Projects::MergeRequestsController do
context 'when filtering by opened state' do
context 'with opened merge requests' do
- it 'should list those merge requests' do
+ it 'lists those merge requests' do
get_merge_requests
expect(assigns(:merge_requests)).to include(merge_request)
@@ -131,7 +131,7 @@ describe Projects::MergeRequestsController do
merge_request.reopen!
end
- it 'should list those merge requests' do
+ it 'lists those merge requests' do
get_merge_requests
expect(assigns(:merge_requests)).to include(merge_request)
diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb
index d173bb350f1..4e3ef5dc6fa 100644
--- a/spec/controllers/projects/milestones_controller_spec.rb
+++ b/spec/controllers/projects/milestones_controller_spec.rb
@@ -14,7 +14,7 @@ describe Projects::MilestonesController do
end
describe "#destroy" do
- it "should remove milestone" do
+ it "removes milestone" do
expect(issue.milestone_id).to eq(milestone.id)
delete :destroy, namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :js
diff --git a/spec/controllers/projects/protected_branches_controller_spec.rb b/spec/controllers/projects/protected_branches_controller_spec.rb
index 596d8d34b7c..da6112a13f7 100644
--- a/spec/controllers/projects/protected_branches_controller_spec.rb
+++ b/spec/controllers/projects/protected_branches_controller_spec.rb
@@ -3,7 +3,7 @@ require('spec_helper')
describe Projects::ProtectedBranchesController do
describe "GET #index" do
let(:project) { create(:project_empty_repo, :public) }
- it "redirect empty repo to projects page" do
+ it "redirects empty repo to projects page" do
get(:index, namespace_id: project.namespace.to_param, project_id: project.to_param)
end
end
diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb
index 48f799d8ca1..04bd9a01f7b 100644
--- a/spec/controllers/projects/raw_controller_spec.rb
+++ b/spec/controllers/projects/raw_controller_spec.rb
@@ -24,7 +24,7 @@ describe Projects::RawController do
context 'image header' do
let(:id) { 'master/files/images/6049019_460s.jpg' }
- it 'set image content type header' do
+ it 'sets image content type header' do
get(:show,
namespace_id: public_project.namespace.to_param,
project_id: public_project.to_param,
diff --git a/spec/controllers/projects/services_controller_spec.rb b/spec/controllers/projects/services_controller_spec.rb
index ccd8c741c83..cccd492ef06 100644
--- a/spec/controllers/projects/services_controller_spec.rb
+++ b/spec/controllers/projects/services_controller_spec.rb
@@ -19,7 +19,7 @@ describe Projects::ServicesController do
describe "#test" do
context 'success' do
- it "should redirect and show success message" do
+ it "redirects and show success message" do
expect(service).to receive(:test).and_return({ success: true, result: 'done' })
get :test, namespace_id: project.namespace.id, project_id: project.id, id: service.id, format: :html
expect(response.status).to redirect_to('/')
@@ -28,7 +28,7 @@ describe Projects::ServicesController do
end
context 'failure' do
- it "should redirect and show failure message" do
+ it "redirects and show failure message" do
expect(service).to receive(:test).and_return({ success: false, result: 'Bad test' })
get :test, namespace_id: project.namespace.id, project_id: project.id, id: service.id, format: :html
expect(response.status).to redirect_to('/')
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 3edce4d339c..ffe0641ddd7 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -128,7 +128,7 @@ describe ProjectsController do
context "when the url contains .atom" do
let(:public_project_with_dot_atom) { build(:project, :public, name: 'my.atom', path: 'my.atom') }
- it 'expect an error creating the project' do
+ it 'expects an error creating the project' do
expect(public_project_with_dot_atom).not_to be_valid
end
end
@@ -222,7 +222,7 @@ describe ProjectsController do
create(:forked_project_link, forked_to_project: project_fork)
end
- it 'should remove fork from project' do
+ it 'removes fork from project' do
delete(:remove_fork,
namespace_id: project_fork.namespace.to_param,
id: project_fork.to_param, format: :js)
@@ -236,7 +236,7 @@ describe ProjectsController do
context 'when project not forked' do
let(:unforked_project) { create(:project, namespace: user.namespace) }
- it 'should do nothing if project was not forked' do
+ it 'does nothing if project was not forked' do
delete(:remove_fork,
namespace_id: unforked_project.namespace.to_param,
id: unforked_project.to_param, format: :js)
@@ -256,7 +256,7 @@ describe ProjectsController do
end
describe "GET refs" do
- it "should get a list of branches and tags" do
+ it "gets a list of branches and tags" do
get :refs, namespace_id: public_project.namespace.path, id: public_project.path
parsed_body = JSON.parse(response.body)
@@ -265,7 +265,7 @@ describe ProjectsController do
expect(parsed_body["Commits"]).to be_nil
end
- it "should get a list of branches, tags and commits" do
+ it "gets a list of branches, tags and commits" do
get :refs, namespace_id: public_project.namespace.path, id: public_project.path, ref: "123456"
parsed_body = JSON.parse(response.body)
diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb
index 675d9bd18b7..786e1456f5f 100644
--- a/spec/factories_spec.rb
+++ b/spec/factories_spec.rb
@@ -9,7 +9,7 @@ describe 'factories' do
expect { entity }.not_to raise_error
end
- it 'should be valid', if: factory.build_class < ActiveRecord::Base do
+ it 'is valid', if: factory.build_class < ActiveRecord::Base do
expect(entity).to be_valid
end
end
diff --git a/spec/features/admin/admin_abuse_reports_spec.rb b/spec/features/admin/admin_abuse_reports_spec.rb
index 16baf7e9516..c1731e6414a 100644
--- a/spec/features/admin/admin_abuse_reports_spec.rb
+++ b/spec/features/admin/admin_abuse_reports_spec.rb
@@ -11,7 +11,7 @@ describe "Admin::AbuseReports", feature: true, js: true do
end
describe 'in the abuse report view' do
- it "should present a link to the user's profile" do
+ it "presents a link to the user's profile" do
visit admin_abuse_reports_path
expect(page).to have_link user.name, href: user_path(user)
@@ -19,7 +19,7 @@ describe "Admin::AbuseReports", feature: true, js: true do
end
describe 'in the profile page of the user' do
- it 'should show a link to the admin view of the user' do
+ it 'shows a link to the admin view of the user' do
visit user_path(user)
expect(page).to have_link '', href: admin_user_path(user)
diff --git a/spec/features/admin/admin_disables_git_access_protocol_spec.rb b/spec/features/admin/admin_disables_git_access_protocol_spec.rb
index 5b1c0460274..66044b44495 100644
--- a/spec/features/admin/admin_disables_git_access_protocol_spec.rb
+++ b/spec/features/admin/admin_disables_git_access_protocol_spec.rb
@@ -45,7 +45,6 @@ feature 'Admin disables Git access protocol', feature: true do
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
expect(page).to have_selector('#clone-dropdown')
end
-
end
def visit_project
diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb
index 7964951ae99..b3ce72b1452 100644
--- a/spec/features/admin/admin_hooks_spec.rb
+++ b/spec/features/admin/admin_hooks_spec.rb
@@ -9,7 +9,7 @@ describe "Admin::Hooks", feature: true do
end
describe "GET /admin/hooks" do
- it "should be ok" do
+ it "is ok" do
visit admin_root_path
page.within ".layout-nav" do
@@ -19,7 +19,7 @@ describe "Admin::Hooks", feature: true do
expect(current_path).to eq(admin_hooks_path)
end
- it "should have hooks list" do
+ it "has hooks list" do
visit admin_hooks_path
expect(page).to have_content(@system_hook.url)
end
@@ -33,7 +33,7 @@ describe "Admin::Hooks", feature: true do
expect { click_button "Add System Hook" }.to change(SystemHook, :count).by(1)
end
- it "should open new hook popup" do
+ it "opens new hook popup" do
expect(current_path).to eq(admin_hooks_path)
expect(page).to have_content(@url)
end
diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb
index 101d955d693..30ded9202a4 100644
--- a/spec/features/admin/admin_projects_spec.rb
+++ b/spec/features/admin/admin_projects_spec.rb
@@ -11,11 +11,11 @@ describe "Admin::Projects", feature: true do
visit admin_namespaces_projects_path
end
- it "should be ok" do
+ it "is ok" do
expect(current_path).to eq(admin_namespaces_projects_path)
end
- it "should have projects list" do
+ it "has projects list" do
expect(page).to have_content(@project.name)
end
end
@@ -26,7 +26,7 @@ describe "Admin::Projects", feature: true do
click_link "#{@project.name}"
end
- it "should have project info" do
+ it "has project info" do
expect(page).to have_content(@project.path)
expect(page).to have_content(@project.name)
end
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index 767504df251..cb3191dfdde 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -8,11 +8,11 @@ describe "Admin::Users", feature: true do
visit admin_users_path
end
- it "should be ok" do
+ it "is ok" do
expect(current_path).to eq(admin_users_path)
end
- it "should have users list" do
+ it "has users list" do
expect(page).to have_content(@user.email)
expect(page).to have_content(@user.name)
end
@@ -66,11 +66,11 @@ describe "Admin::Users", feature: true do
fill_in "user_email", with: "bigbang@mail.com"
end
- it "should create new user" do
+ it "creates new user" do
expect { click_button "Create user" }.to change {User.count}.by(1)
end
- it "should apply defaults to user" do
+ it "applies defaults to user" do
click_button "Create user"
user = User.find_by(username: 'bang')
expect(user.projects_limit).
@@ -79,20 +79,20 @@ describe "Admin::Users", feature: true do
to eq(Gitlab.config.gitlab.default_can_create_group)
end
- it "should create user with valid data" do
+ it "creates user with valid data" do
click_button "Create user"
user = User.find_by(username: 'bang')
expect(user.name).to eq('Big Bang')
expect(user.email).to eq('bigbang@mail.com')
end
- it "should call send mail" do
+ it "calls send mail" do
expect_any_instance_of(NotificationService).to receive(:new_user)
click_button "Create user"
end
- it "should send valid email to user with email & password" do
+ it "sends valid email to user with email & password" do
perform_enqueued_jobs do
click_button "Create user"
end
@@ -106,7 +106,7 @@ describe "Admin::Users", feature: true do
end
describe "GET /admin/users/:id" do
- it "should have user info" do
+ it "has user info" do
visit admin_users_path
click_link @user.name
@@ -123,13 +123,13 @@ describe "Admin::Users", feature: true do
expect(page).to have_content('Impersonate')
end
- it 'should not show impersonate button for admin itself' do
+ it 'does not show impersonate button for admin itself' do
visit admin_user_path(@user)
expect(page).not_to have_content('Impersonate')
end
- it 'should not show impersonate button for blocked user' do
+ it 'does not show impersonate button for blocked user' do
another_user.block
visit admin_user_path(another_user)
@@ -153,7 +153,7 @@ describe "Admin::Users", feature: true do
expect(icon).not_to eql nil
end
- it 'can log out of impersonated user back to original user' do
+ it 'logs out of impersonated user back to original user' do
find(:css, 'li.impersonation a').click
expect(page.find(:css, '.header-user .profile-link')['data-user']).to eql(@user.username)
@@ -197,7 +197,7 @@ describe "Admin::Users", feature: true do
click_link "edit_user_#{@simple_user.id}"
end
- it "should have user edit page" do
+ it "has user edit page" do
expect(page).to have_content('Name')
expect(page).to have_content('Password')
end
@@ -212,12 +212,12 @@ describe "Admin::Users", feature: true do
click_button "Save changes"
end
- it "should show page with new data" do
+ it "shows page with new data" do
expect(page).to have_content('bigbang@mail.com')
expect(page).to have_content('Big Bang')
end
- it "should change user entry" do
+ it "changes user entry" do
@simple_user.reload
expect(@simple_user.name).to eq('Big Bang')
expect(@simple_user.is_admin?).to be_truthy
diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb
index f81a3c117ff..746df36bb25 100644
--- a/spec/features/atom/dashboard_spec.rb
+++ b/spec/features/atom/dashboard_spec.rb
@@ -5,7 +5,7 @@ describe "Dashboard Feed", feature: true do
let!(:user) { create(:user, name: "Jonh") }
context "projects atom feed via private token" do
- it "should render projects atom feed" do
+ it "renders projects atom feed" do
visit dashboard_projects_path(:atom, private_token: user.private_token)
expect(body).to have_selector('feed title')
end
@@ -23,11 +23,11 @@ describe "Dashboard Feed", feature: true do
visit dashboard_projects_path(:atom, private_token: user.private_token)
end
- it "should have issue opened event" do
+ it "has issue opened event" do
expect(body).to have_content("#{user.name} opened issue ##{issue.iid}")
end
- it "should have issue comment event" do
+ it "has issue comment event" do
expect(body).
to have_content("#{user.name} commented on issue ##{issue.iid}")
end
diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb
index baa7814e96a..09c140868fb 100644
--- a/spec/features/atom/issues_spec.rb
+++ b/spec/features/atom/issues_spec.rb
@@ -9,7 +9,7 @@ describe 'Issues Feed', feature: true do
before { project.team << [user, :developer] }
context 'when authenticated' do
- it 'should render atom feed' do
+ it 'renders atom feed' do
login_with user
visit namespace_project_issues_path(project.namespace, project, :atom)
@@ -22,7 +22,7 @@ describe 'Issues Feed', feature: true do
end
context 'when authenticated via private token' do
- it 'should render atom feed' do
+ it 'renders atom feed' do
visit namespace_project_issues_path(project.namespace, project, :atom,
private_token: user.private_token)
diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb
index 91704377a07..a8833194421 100644
--- a/spec/features/atom/users_spec.rb
+++ b/spec/features/atom/users_spec.rb
@@ -5,7 +5,7 @@ describe "User Feed", feature: true do
let!(:user) { create(:user) }
context 'user atom feed via private token' do
- it "should render user atom feed" do
+ it "renders user atom feed" do
visit user_path(user, :atom, private_token: user.private_token)
expect(body).to have_selector('feed title')
end
@@ -43,24 +43,24 @@ describe "User Feed", feature: true do
visit user_path(user, :atom, private_token: user.private_token)
end
- it 'should have issue opened event' do
+ it 'has issue opened event' do
expect(body).to have_content("#{safe_name} opened issue ##{issue.iid}")
end
- it 'should have issue comment event' do
+ it 'has issue comment event' do
expect(body).
to have_content("#{safe_name} commented on issue ##{issue.iid}")
end
- it 'should have XHTML summaries in issue descriptions' do
+ it 'has XHTML summaries in issue descriptions' do
expect(body).to match /we have a bug!<\/p>\n\n<hr ?\/>\n\n<p>I guess/
end
- it 'should have XHTML summaries in notes' do
+ it 'has XHTML summaries in notes' do
expect(body).to match /Bug confirmed <img[^>]*\/>/
end
- it 'should have XHTML summaries in merge request descriptions' do
+ it 'has XHTML summaries in merge request descriptions' do
expect(body).to match /Here is the fix: <\/p><div[^>]*><a[^>]*><img[^>]*\/><\/a><\/div>/
end
end
diff --git a/spec/features/ci_lint_spec.rb b/spec/features/ci_lint_spec.rb
index 30e29d9d552..81077f4b005 100644
--- a/spec/features/ci_lint_spec.rb
+++ b/spec/features/ci_lint_spec.rb
@@ -17,7 +17,7 @@ describe 'CI Lint' do
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
- it 'Yaml parsing' do
+ it 'parses Yaml' do
within "table" do
expect(page).to have_content('Job - rspec')
expect(page).to have_content('Job - spinach')
diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb
index 45e1a157a1f..5910803df51 100644
--- a/spec/features/commits_spec.rb
+++ b/spec/features/commits_spec.rb
@@ -52,7 +52,7 @@ describe 'Commits' do
visit namespace_project_commits_path(project.namespace, project, :master)
end
- it 'should show build status' do
+ it 'shows build status' do
page.within("//li[@id='commit-#{pipeline.short_sha}']") do
expect(page).to have_css(".ci-status-link")
end
diff --git a/spec/features/compare_spec.rb b/spec/features/compare_spec.rb
index c62556948e0..ca7f73e24cc 100644
--- a/spec/features/compare_spec.rb
+++ b/spec/features/compare_spec.rb
@@ -11,11 +11,11 @@ describe "Compare", js: true do
end
describe "branches" do
- it "should pre-populate fields" do
+ it "pre-populates fields" do
expect(page.find_field("from").value).to eq("master")
end
- it "should compare branches" do
+ it "compares branches" do
fill_in "from", with: "fea"
find("#from").click
@@ -28,7 +28,7 @@ describe "Compare", js: true do
end
describe "tags" do
- it "should compare tags" do
+ it "compares tags" do
fill_in "from", with: "v1.0"
find("#from").click
diff --git a/spec/features/dashboard/label_filter_spec.rb b/spec/features/dashboard/label_filter_spec.rb
index 24e83d44010..4cff12de854 100644
--- a/spec/features/dashboard/label_filter_spec.rb
+++ b/spec/features/dashboard/label_filter_spec.rb
@@ -16,7 +16,7 @@ describe 'Dashboard > label filter', feature: true, js: true do
end
context 'duplicate labels' do
- it 'should remove duplicate labels' do
+ it 'removes duplicate labels' do
page.within('.labels-filter') do
click_button 'Label'
end
diff --git a/spec/features/dashboard_issues_spec.rb b/spec/features/dashboard_issues_spec.rb
index 39805da9d0b..3fb1cb37544 100644
--- a/spec/features/dashboard_issues_spec.rb
+++ b/spec/features/dashboard_issues_spec.rb
@@ -16,7 +16,7 @@ describe "Dashboard Issues filtering", feature: true, js: true do
visit_issues
end
- it 'should show all issues with no milestone' do
+ it 'shows all issues with no milestone' do
show_milestone_dropdown
click_link 'No Milestone'
@@ -24,7 +24,7 @@ describe "Dashboard Issues filtering", feature: true, js: true do
expect(page).to have_selector('.issue', count: 1)
end
- it 'should show all issues with any milestone' do
+ it 'shows all issues with any milestone' do
show_milestone_dropdown
click_link 'Any Milestone'
@@ -32,7 +32,7 @@ describe "Dashboard Issues filtering", feature: true, js: true do
expect(page).to have_selector('.issue', count: 2)
end
- it 'should show all issues with the selected milestone' do
+ it 'shows all issues with the selected milestone' do
show_milestone_dropdown
page.within '.dropdown-content' do
diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb
index a89ac09f236..84d73d693bc 100644
--- a/spec/features/gitlab_flavored_markdown_spec.rb
+++ b/spec/features/gitlab_flavored_markdown_spec.rb
@@ -23,25 +23,25 @@ describe "GitLab Flavored Markdown", feature: true do
end
describe "for commits" do
- it "should render title in commits#index" do
+ it "renders title in commits#index" do
visit namespace_project_commits_path(project.namespace, project, 'master', limit: 1)
expect(page).to have_link(issue.to_reference)
end
- it "should render title in commits#show" do
+ it "renders title in commits#show" do
visit namespace_project_commit_path(project.namespace, project, commit)
expect(page).to have_link(issue.to_reference)
end
- it "should render description in commits#show" do
+ it "renders description in commits#show" do
visit namespace_project_commit_path(project.namespace, project, commit)
expect(page).to have_link(fred.to_reference)
end
- it "should render title in repositories#branches" do
+ it "renders title in repositories#branches" do
visit namespace_project_branches_path(project.namespace, project)
expect(page).to have_link(issue.to_reference)
@@ -62,19 +62,19 @@ describe "GitLab Flavored Markdown", feature: true do
description: "ask #{fred.to_reference} for details")
end
- it "should render subject in issues#index" do
+ it "renders subject in issues#index" do
visit namespace_project_issues_path(project.namespace, project)
expect(page).to have_link(@other_issue.to_reference)
end
- it "should render subject in issues#show" do
+ it "renders subject in issues#show" do
visit namespace_project_issue_path(project.namespace, project, @issue)
expect(page).to have_link(@other_issue.to_reference)
end
- it "should render details in issues#show" do
+ it "renders details in issues#show" do
visit namespace_project_issue_path(project.namespace, project, @issue)
expect(page).to have_link(fred.to_reference)
@@ -86,13 +86,13 @@ describe "GitLab Flavored Markdown", feature: true do
@merge_request = create(:merge_request, source_project: project, target_project: project, title: "fix #{issue.to_reference}")
end
- it "should render title in merge_requests#index" do
+ it "renders title in merge_requests#index" do
visit namespace_project_merge_requests_path(project.namespace, project)
expect(page).to have_link(issue.to_reference)
end
- it "should render title in merge_requests#show" do
+ it "renders title in merge_requests#show" do
visit namespace_project_merge_request_path(project.namespace, project, @merge_request)
expect(page).to have_link(issue.to_reference)
@@ -107,19 +107,19 @@ describe "GitLab Flavored Markdown", feature: true do
description: "ask #{fred.to_reference} for details")
end
- it "should render title in milestones#index" do
+ it "renders title in milestones#index" do
visit namespace_project_milestones_path(project.namespace, project)
expect(page).to have_link(issue.to_reference)
end
- it "should render title in milestones#show" do
+ it "renders title in milestones#show" do
visit namespace_project_milestone_path(project.namespace, project, @milestone)
expect(page).to have_link(issue.to_reference)
end
- it "should render description in milestones#show" do
+ it "renders description in milestones#show" do
visit namespace_project_milestone_path(project.namespace, project, @milestone)
expect(page).to have_link(fred.to_reference)
diff --git a/spec/features/help_pages_spec.rb b/spec/features/help_pages_spec.rb
index 1e2306d7f59..e2101b333e2 100644
--- a/spec/features/help_pages_spec.rb
+++ b/spec/features/help_pages_spec.rb
@@ -5,7 +5,7 @@ describe 'Help Pages', feature: true do
before do
login_as :user
end
- it 'replace the variable $your_email with the email of the user' do
+ it 'replaces the variable $your_email with the email of the user' do
visit help_page_path('ssh/README')
expect(page).to have_content("ssh-keygen -t rsa -C \"#{@user.email}\"")
end
diff --git a/spec/features/issues/award_emoji_spec.rb b/spec/features/issues/award_emoji_spec.rb
index 07a854ea014..6eb04cf74c5 100644
--- a/spec/features/issues/award_emoji_spec.rb
+++ b/spec/features/issues/award_emoji_spec.rb
@@ -21,32 +21,32 @@ describe 'Awards Emoji', feature: true do
visit namespace_project_issue_path(project.namespace, project, issue)
end
- it 'should increment the thumbsdown emoji', js: true do
+ it 'increments the thumbsdown emoji', js: true do
find('[data-emoji="thumbsdown"]').click
sleep 2
expect(thumbsdown_emoji).to have_text("1")
end
context 'click the thumbsup emoji' do
- it 'should increment the thumbsup emoji', js: true do
+ it 'increments the thumbsup emoji', js: true do
find('[data-emoji="thumbsup"]').click
sleep 2
expect(thumbsup_emoji).to have_text("1")
end
- it 'should decrement the thumbsdown emoji', js: true do
+ it 'decrements the thumbsdown emoji', js: true do
expect(thumbsdown_emoji).to have_text("0")
end
end
context 'click the thumbsdown emoji' do
- it 'should increment the thumbsdown emoji', js: true do
+ it 'increments the thumbsdown emoji', js: true do
find('[data-emoji="thumbsdown"]').click
sleep 2
expect(thumbsdown_emoji).to have_text("1")
end
- it 'should decrement the thumbsup emoji', js: true do
+ it 'decrements the thumbsup emoji', js: true do
expect(thumbsup_emoji).to have_text("0")
end
end
diff --git a/spec/features/issues/award_spec.rb b/spec/features/issues/award_spec.rb
index 63efecf8780..401e1ea2b89 100644
--- a/spec/features/issues/award_spec.rb
+++ b/spec/features/issues/award_spec.rb
@@ -11,7 +11,7 @@ feature 'Issue awards', js: true, feature: true do
visit namespace_project_issue_path(project.namespace, project, issue)
end
- it 'should add award to issue' do
+ it 'adds award to issue' do
first('.js-emoji-btn').click
expect(page).to have_selector('.js-emoji-btn.active')
expect(first('.js-emoji-btn')).to have_content '1'
@@ -20,7 +20,7 @@ feature 'Issue awards', js: true, feature: true do
expect(first('.js-emoji-btn')).to have_content '1'
end
- it 'should remove award from issue' do
+ it 'removes award from issue' do
first('.js-emoji-btn').click
find('.js-emoji-btn.active').click
expect(first('.js-emoji-btn')).to have_content '0'
@@ -29,7 +29,7 @@ feature 'Issue awards', js: true, feature: true do
expect(first('.js-emoji-btn')).to have_content '0'
end
- it 'should only have one menu on the page' do
+ it 'only has one menu on the page' do
first('.js-add-award').click
expect(page).to have_selector('.emoji-menu')
@@ -42,7 +42,7 @@ feature 'Issue awards', js: true, feature: true do
visit namespace_project_issue_path(project.namespace, project, issue)
end
- it 'should not see award menu button' do
+ it 'does not see award menu button' do
expect(page).not_to have_selector('.js-award-holder')
end
end
diff --git a/spec/features/issues/bulk_assignment_labels_spec.rb b/spec/features/issues/bulk_assignment_labels_spec.rb
index afc093cc1f5..bc2c087c9b9 100644
--- a/spec/features/issues/bulk_assignment_labels_spec.rb
+++ b/spec/features/issues/bulk_assignment_labels_spec.rb
@@ -175,7 +175,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
visit namespace_project_issues_path(project.namespace, project)
end
- it 'labels are kept' do
+ it 'keeps labels' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
@@ -197,7 +197,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
visit namespace_project_issues_path(project.namespace, project)
end
- it 'existing label is kept and new label is present' do
+ it 'keeps existing label and new label is present' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
check 'check_all_issues'
@@ -222,7 +222,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
visit namespace_project_issues_path(project.namespace, project)
end
- it 'existing label is kept and new label is present' do
+ it 'keeps existing label and new label is present' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
@@ -252,7 +252,7 @@ feature 'Issues > Labels bulk assignment', feature: true do
visit namespace_project_issues_path(project.namespace, project)
end
- it 'labels are kept' do
+ it 'keeps labels' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'First Release'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb
index cb117d2476f..908b18e5339 100644
--- a/spec/features/issues/filter_by_labels_spec.rb
+++ b/spec/features/issues/filter_by_labels_spec.rb
@@ -37,25 +37,25 @@ feature 'Issue filtering by Labels', feature: true do
wait_for_ajax
end
- it 'should show issue "Bugfix1" and "Bugfix2" in issues list' do
+ it 'shows issue "Bugfix1" and "Bugfix2" in issues list' do
expect(page).to have_content "Bugfix1"
expect(page).to have_content "Bugfix2"
end
- it 'should not show "Feature1" in issues list' do
+ it 'does not show "Feature1" in issues list' do
expect(page).not_to have_content "Feature1"
end
- it 'should show label "bug" in filtered-labels' do
+ it 'shows label "bug" in filtered-labels' do
expect(find('.filtered-labels')).to have_content "bug"
end
- it 'should not show label "feature" and "enhancement" in filtered-labels' do
+ it 'does not show label "feature" and "enhancement" in filtered-labels' do
expect(find('.filtered-labels')).not_to have_content "feature"
expect(find('.filtered-labels')).not_to have_content "enhancement"
end
- it 'should remove label "bug"' do
+ it 'removes label "bug"' do
find('.js-label-filter-remove').click
wait_for_ajax
expect(find('.filtered-labels', visible: false)).to have_no_content "bug"
@@ -71,20 +71,20 @@ feature 'Issue filtering by Labels', feature: true do
wait_for_ajax
end
- it 'should show issue "Feature1" in issues list' do
+ it 'shows issue "Feature1" in issues list' do
expect(page).to have_content "Feature1"
end
- it 'should not show "Bugfix1" and "Bugfix2" in issues list' do
+ it 'does not show "Bugfix1" and "Bugfix2" in issues list' do
expect(page).not_to have_content "Bugfix2"
expect(page).not_to have_content "Bugfix1"
end
- it 'should show label "feature" in filtered-labels' do
+ it 'shows label "feature" in filtered-labels' do
expect(find('.filtered-labels')).to have_content "feature"
end
- it 'should not show label "bug" and "enhancement" in filtered-labels' do
+ it 'does not show label "bug" and "enhancement" in filtered-labels' do
expect(find('.filtered-labels')).not_to have_content "bug"
expect(find('.filtered-labels')).not_to have_content "enhancement"
end
@@ -99,20 +99,20 @@ feature 'Issue filtering by Labels', feature: true do
wait_for_ajax
end
- it 'should show issue "Bugfix2" in issues list' do
+ it 'shows issue "Bugfix2" in issues list' do
expect(page).to have_content "Bugfix2"
end
- it 'should not show "Feature1" and "Bugfix1" in issues list' do
+ it 'does not show "Feature1" and "Bugfix1" in issues list' do
expect(page).not_to have_content "Feature1"
expect(page).not_to have_content "Bugfix1"
end
- it 'should show label "enhancement" in filtered-labels' do
+ it 'shows label "enhancement" in filtered-labels' do
expect(find('.filtered-labels')).to have_content "enhancement"
end
- it 'should not show label "feature" and "bug" in filtered-labels' do
+ it 'does not show label "feature" and "bug" in filtered-labels' do
expect(find('.filtered-labels')).not_to have_content "bug"
expect(find('.filtered-labels')).not_to have_content "feature"
end
@@ -128,21 +128,21 @@ feature 'Issue filtering by Labels', feature: true do
wait_for_ajax
end
- it 'should not show "Bugfix1" or "Feature1" in issues list' do
+ it 'does not show "Bugfix1" or "Feature1" in issues list' do
expect(page).not_to have_content "Bugfix1"
expect(page).not_to have_content "Feature1"
end
- it 'should show label "enhancement" and "feature" in filtered-labels' do
+ it 'shows label "enhancement" and "feature" in filtered-labels' do
expect(find('.filtered-labels')).to have_content "enhancement"
expect(find('.filtered-labels')).to have_content "feature"
end
- it 'should not show label "bug" in filtered-labels' do
+ it 'does not show label "bug" in filtered-labels' do
expect(find('.filtered-labels')).not_to have_content "bug"
end
- it 'should remove label "enhancement"' do
+ it 'removes label "enhancement"' do
find('.js-label-filter-remove', match: :first).click
wait_for_ajax
expect(find('.filtered-labels')).to have_no_content "enhancement"
@@ -159,20 +159,20 @@ feature 'Issue filtering by Labels', feature: true do
wait_for_ajax
end
- it 'should show issue "Bugfix2" in issues list' do
+ it 'shows issue "Bugfix2" in issues list' do
expect(page).to have_content "Bugfix2"
end
- it 'should not show "Feature1"' do
+ it 'does not show "Feature1"' do
expect(page).not_to have_content "Feature1"
end
- it 'should show label "bug" and "enhancement" in filtered-labels' do
+ it 'shows label "bug" and "enhancement" in filtered-labels' do
expect(find('.filtered-labels')).to have_content "bug"
expect(find('.filtered-labels')).to have_content "enhancement"
end
- it 'should not show label "feature" in filtered-labels' do
+ it 'does not show label "feature" in filtered-labels' do
expect(find('.filtered-labels')).not_to have_content "feature"
end
end
@@ -191,7 +191,7 @@ feature 'Issue filtering by Labels', feature: true do
end
end
- it 'should allow user to remove filtered labels' do
+ it 'allows user to remove filtered labels' do
first('.js-label-filter-remove').click
wait_for_ajax
@@ -201,7 +201,7 @@ feature 'Issue filtering by Labels', feature: true do
end
context 'dropdown filtering', js: true do
- it 'should filter by label name' do
+ it 'filters by label name' do
page.within '.labels-filter' do
click_button 'Label'
wait_for_ajax
diff --git a/spec/features/issues/filter_by_milestone_spec.rb b/spec/features/issues/filter_by_milestone_spec.rb
index 99445185893..485dc560061 100644
--- a/spec/features/issues/filter_by_milestone_spec.rb
+++ b/spec/features/issues/filter_by_milestone_spec.rb
@@ -15,7 +15,7 @@ feature 'Issue filtering by Milestone', feature: true do
end
context 'filters by upcoming milestone', js: true do
- it 'should not show issues with no expiry' do
+ it 'does not show issues with no expiry' do
create(:issue, project: project)
create(:issue, project: project, milestone: milestone)
@@ -25,7 +25,7 @@ feature 'Issue filtering by Milestone', feature: true do
expect(page).to have_css('.issue', count: 0)
end
- it 'should show issues in future' do
+ it 'shows issues in future' do
milestone = create(:milestone, project: project, due_date: Date.tomorrow)
create(:issue, project: project)
create(:issue, project: project, milestone: milestone)
@@ -36,7 +36,7 @@ feature 'Issue filtering by Milestone', feature: true do
expect(page).to have_css('.issue', count: 1)
end
- it 'should not show issues in past' do
+ it 'does not show issues in past' do
milestone = create(:milestone, project: project, due_date: Date.yesterday)
create(:issue, project: project)
create(:issue, project: project, milestone: milestone)
diff --git a/spec/features/issues/filter_issues_spec.rb b/spec/features/issues/filter_issues_spec.rb
index 4b9b5394b61..ea81ee54c90 100644
--- a/spec/features/issues/filter_issues_spec.rb
+++ b/spec/features/issues/filter_issues_spec.rb
@@ -26,17 +26,17 @@ describe 'Filter issues', feature: true do
end
context 'assignee', js: true do
- it 'should update to current user' do
+ it 'updates to current user' do
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
end
- it 'should not change when closed link is clicked' do
+ it 'does not change when closed link is clicked' do
find('.issues-state-filters a', text: "Closed").click
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
end
- it 'should not change when all link is clicked' do
+ it 'does not change when all link is clicked' do
find('.issues-state-filters a', text: "All").click
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
@@ -56,17 +56,17 @@ describe 'Filter issues', feature: true do
end
context 'milestone', js: true do
- it 'should update to current milestone' do
+ it 'updates to current milestone' do
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title)
end
- it 'should not change when closed link is clicked' do
+ it 'does not change when closed link is clicked' do
find('.issues-state-filters a', text: "Closed").click
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title)
end
- it 'should not change when all link is clicked' do
+ it 'does not change when all link is clicked' do
find('.issues-state-filters a', text: "All").click
expect(find('.js-milestone-select .dropdown-toggle-text')).to have_content(milestone.title)
@@ -81,7 +81,7 @@ describe 'Filter issues', feature: true do
wait_for_ajax
end
- it 'should filter by any label' do
+ it 'filters by any label' do
find('.dropdown-menu-labels a', text: 'Any Label').click
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
wait_for_ajax
@@ -89,7 +89,7 @@ describe 'Filter issues', feature: true do
expect(find('.labels-filter')).to have_content 'Label'
end
- it 'should filter by no label' do
+ it 'filters by no label' do
find('.dropdown-menu-labels a', text: 'No Label').click
page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
wait_for_ajax
@@ -100,7 +100,7 @@ describe 'Filter issues', feature: true do
expect(find('.js-label-select .dropdown-toggle-text')).to have_content('No Label')
end
- it 'should filter by no label' do
+ it 'filters by no label' do
find('.dropdown-menu-labels a', text: label.title).click
page.within '.labels-filter' do
expect(page).to have_content label.title
@@ -128,19 +128,19 @@ describe 'Filter issues', feature: true do
end
context 'assignee and label', js: true do
- it 'should update to current assignee and label' do
+ it 'updates to current assignee and label' do
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
end
- it 'should not change when closed link is clicked' do
+ it 'does not change when closed link is clicked' do
find('.issues-state-filters a', text: "Closed").click
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
end
- it 'should not change when all link is clicked' do
+ it 'does not change when all link is clicked' do
find('.issues-state-filters a', text: "All").click
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
@@ -168,7 +168,7 @@ describe 'Filter issues', feature: true do
end
context 'only text', js: true do
- it 'should filter issues by searched text' do
+ it 'filters issues by searched text' do
fill_in 'issue_search', with: 'Bug'
page.within '.issues-list' do
@@ -176,7 +176,7 @@ describe 'Filter issues', feature: true do
end
end
- it 'should not show any issues' do
+ it 'does not show any issues' do
fill_in 'issue_search', with: 'testing'
page.within '.issues-list' do
@@ -186,7 +186,7 @@ describe 'Filter issues', feature: true do
end
context 'text and dropdown options', js: true do
- it 'should filter by text and label' do
+ it 'filters by text and label' do
fill_in 'issue_search', with: 'Bug'
page.within '.issues-list' do
@@ -204,7 +204,7 @@ describe 'Filter issues', feature: true do
end
end
- it 'should filter by text and milestone' do
+ it 'filters by text and milestone' do
fill_in 'issue_search', with: 'Bug'
page.within '.issues-list' do
@@ -221,7 +221,7 @@ describe 'Filter issues', feature: true do
end
end
- it 'should filter by text and assignee' do
+ it 'filters by text and assignee' do
fill_in 'issue_search', with: 'Bug'
page.within '.issues-list' do
@@ -238,7 +238,7 @@ describe 'Filter issues', feature: true do
end
end
- it 'should filter by text and author' do
+ it 'filters by text and author' do
fill_in 'issue_search', with: 'Bug'
page.within '.issues-list' do
@@ -269,7 +269,7 @@ describe 'Filter issues', feature: true do
visit namespace_project_issues_path(project.namespace, project)
end
- it 'should be able to filter and sort issues' do
+ it 'is able to filter and sort issues' do
click_button 'Label'
wait_for_ajax
page.within '.labels-filter' do
diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb
index 5739bc64dfb..4b1aec8bf71 100644
--- a/spec/features/issues/issue_sidebar_spec.rb
+++ b/spec/features/issues/issue_sidebar_spec.rb
@@ -17,7 +17,7 @@ feature 'Issue Sidebar', feature: true do
end
describe 'when clicking on edit labels', js: true do
- it 'dropdown has an option to create a new label' do
+ it 'shows dropdown option to create a new label' do
find('.block.labels .edit-link').click
page.within('.block.labels') do
@@ -27,7 +27,7 @@ feature 'Issue Sidebar', feature: true do
end
context 'creating a new label', js: true do
- it 'option to crate a new label is present' do
+ it 'shows option to crate a new label is present' do
page.within('.block.labels') do
find('.edit-link').click
@@ -35,7 +35,7 @@ feature 'Issue Sidebar', feature: true do
end
end
- it 'dropdown switches to "create label" section' do
+ it 'shows dropdown switches to "create label" section' do
page.within('.block.labels') do
find('.edit-link').click
click_link 'Create new'
@@ -44,7 +44,7 @@ feature 'Issue Sidebar', feature: true do
end
end
- it 'new label is added' do
+ it 'adds new label' do
page.within('.block.labels') do
find('.edit-link').click
sleep 1
diff --git a/spec/features/issues/new_branch_button_spec.rb b/spec/features/issues/new_branch_button_spec.rb
index 16e188d2a8a..e528aff4d41 100644
--- a/spec/features/issues/new_branch_button_spec.rb
+++ b/spec/features/issues/new_branch_button_spec.rb
@@ -41,7 +41,7 @@ feature 'Start new branch from an issue', feature: true do
end
context "for visiters" do
- it 'no button is shown', js: true do
+ it 'shows no buttons', js: true do
visit namespace_project_issue_path(project.namespace, project, issue)
expect(page).not_to have_css('#new-branch')
diff --git a/spec/features/issues/todo_spec.rb b/spec/features/issues/todo_spec.rb
index bc0f437a8ce..de8fdda388d 100644
--- a/spec/features/issues/todo_spec.rb
+++ b/spec/features/issues/todo_spec.rb
@@ -11,7 +11,7 @@ feature 'Manually create a todo item from issue', feature: true, js: true do
visit namespace_project_issue_path(project.namespace, project, issue)
end
- it 'should create todo when clicking button' do
+ it 'creates todo when clicking button' do
page.within '.issuable-sidebar' do
click_button 'Add Todo'
expect(page).to have_content 'Mark Done'
@@ -28,7 +28,7 @@ feature 'Manually create a todo item from issue', feature: true, js: true do
end
end
- it 'should mark a todo as done' do
+ it 'marks a todo as done' do
page.within '.issuable-sidebar' do
click_button 'Add Todo'
click_button 'Mark Done'
diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb
index ddbd69b2891..ae5da3877a8 100644
--- a/spec/features/issues/update_issues_spec.rb
+++ b/spec/features/issues/update_issues_spec.rb
@@ -13,7 +13,7 @@ feature 'Multiple issue updating from issues#index', feature: true do
end
context 'status', js: true do
- it 'should be set to closed' do
+ it 'sets to closed' do
visit namespace_project_issues_path(project.namespace, project)
find('#check_all_issues').click
@@ -24,7 +24,7 @@ feature 'Multiple issue updating from issues#index', feature: true do
expect(page).to have_selector('.issue', count: 0)
end
- it 'should be set to open' do
+ it 'sets to open' do
create_closed
visit namespace_project_issues_path(project.namespace, project, state: 'closed')
@@ -38,7 +38,7 @@ feature 'Multiple issue updating from issues#index', feature: true do
end
context 'assignee', js: true do
- it 'should update to current user' do
+ it 'updates to current user' do
visit namespace_project_issues_path(project.namespace, project)
find('#check_all_issues').click
@@ -52,7 +52,7 @@ feature 'Multiple issue updating from issues#index', feature: true do
end
end
- it 'should update to unassigned' do
+ it 'updates to unassigned' do
create_assigned
visit namespace_project_issues_path(project.namespace, project)
@@ -68,7 +68,7 @@ feature 'Multiple issue updating from issues#index', feature: true do
context 'milestone', js: true do
let(:milestone) { create(:milestone, project: project) }
- it 'should update milestone' do
+ it 'updates milestone' do
visit namespace_project_issues_path(project.namespace, project)
find('#check_all_issues').click
@@ -80,7 +80,7 @@ feature 'Multiple issue updating from issues#index', feature: true do
expect(find('.issue')).to have_content milestone.title
end
- it 'should set to no milestone' do
+ it 'sets to no milestone' do
create_with_milestone
visit namespace_project_issues_path(project.namespace, project)
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index 9c92b52898c..cb445e22af0 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -26,7 +26,7 @@ describe 'Issues', feature: true do
find('.js-zen-enter').click
end
- it 'should open new issue popup' do
+ it 'opens new issue popup' do
expect(page).to have_content("Issue ##{issue.iid}")
end
@@ -71,7 +71,7 @@ describe 'Issues', feature: true do
visit new_namespace_project_issue_path(project.namespace, project)
end
- it 'should save with due date' do
+ it 'saves with due date' do
date = Date.today.at_beginning_of_month
fill_in 'issue_title', with: 'bug 345'
@@ -99,7 +99,7 @@ describe 'Issues', feature: true do
visit edit_namespace_project_issue_path(project.namespace, project, issue)
end
- it 'should save with due date' do
+ it 'saves with due date' do
date = Date.today.at_beginning_of_month
expect(find('#issuable-due-date').value).to eq date.to_s
@@ -155,7 +155,7 @@ describe 'Issues', feature: true do
let(:issue) { @issue }
- it 'should allow filtering by issues with no specified assignee' do
+ it 'allows filtering by issues with no specified assignee' do
visit namespace_project_issues_path(project.namespace, project, assignee_id: IssuableFinder::NONE)
expect(page).to have_content 'foobar'
@@ -163,7 +163,7 @@ describe 'Issues', feature: true do
expect(page).not_to have_content 'gitlab'
end
- it 'should allow filtering by a specified assignee' do
+ it 'allows filtering by a specified assignee' do
visit namespace_project_issues_path(project.namespace, project, assignee_id: @user.id)
expect(page).not_to have_content 'foobar'
@@ -514,7 +514,7 @@ describe 'Issues', feature: true do
visit new_namespace_project_issue_path(project.namespace, project)
end
- it 'should upload file when dragging into textarea' do
+ it 'uploads file when dragging into textarea' do
drop_in_dropzone test_image_file
# Wait for the file to upload
@@ -562,7 +562,7 @@ describe 'Issues', feature: true do
visit namespace_project_issue_path(project.namespace, project, issue)
end
- it 'should add due date to issue' do
+ it 'adds due date to issue' do
page.within '.due_date' do
click_link 'Edit'
@@ -574,7 +574,7 @@ describe 'Issues', feature: true do
end
end
- it 'should remove due date from issue' do
+ it 'removes due date from issue' do
page.within '.due_date' do
click_link 'Edit'
diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb
index c4e8b1da531..2523b4b7898 100644
--- a/spec/features/login_spec.rb
+++ b/spec/features/login_spec.rb
@@ -131,7 +131,7 @@ feature 'Login', feature: true do
expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml')
end
- it 'should show 2FA prompt after OAuth login' do
+ it 'shows 2FA prompt after OAuth login' do
stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config])
user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml')
login_via('saml', user, 'my-uid')
diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_requests/award_spec.rb
index 007f67d6080..ac260e118d0 100644
--- a/spec/features/merge_requests/award_spec.rb
+++ b/spec/features/merge_requests/award_spec.rb
@@ -11,7 +11,7 @@ feature 'Merge request awards', js: true, feature: true do
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
- it 'should add award to merge request' do
+ it 'adds award to merge request' do
first('.js-emoji-btn').click
expect(page).to have_selector('.js-emoji-btn.active')
expect(first('.js-emoji-btn')).to have_content '1'
@@ -20,7 +20,7 @@ feature 'Merge request awards', js: true, feature: true do
expect(first('.js-emoji-btn')).to have_content '1'
end
- it 'should remove award from merge request' do
+ it 'removes award from merge request' do
first('.js-emoji-btn').click
find('.js-emoji-btn.active').click
expect(first('.js-emoji-btn')).to have_content '0'
@@ -29,7 +29,7 @@ feature 'Merge request awards', js: true, feature: true do
expect(first('.js-emoji-btn')).to have_content '0'
end
- it 'should only have one menu on the page' do
+ it 'has only one menu on the page' do
first('.js-add-award').click
expect(page).to have_selector('.emoji-menu')
@@ -42,7 +42,7 @@ feature 'Merge request awards', js: true, feature: true do
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
- it 'should not see award menu button' do
+ it 'does not see award menu button' do
expect(page).not_to have_selector('.js-award-holder')
end
end
diff --git a/spec/features/merge_requests/edit_mr_spec.rb b/spec/features/merge_requests/edit_mr_spec.rb
index 9e007ab7635..4109e78f560 100644
--- a/spec/features/merge_requests/edit_mr_spec.rb
+++ b/spec/features/merge_requests/edit_mr_spec.rb
@@ -14,7 +14,7 @@ feature 'Edit Merge Request', feature: true do
end
context 'editing a MR' do
- it 'form should have class js-quick-submit' do
+ it 'has class js-quick-submit in form' do
expect(page).to have_selector('.js-quick-submit')
end
end
diff --git a/spec/features/merge_requests/filter_by_milestone_spec.rb b/spec/features/merge_requests/filter_by_milestone_spec.rb
index e3ecd60a5f3..bb0bb590a46 100644
--- a/spec/features/merge_requests/filter_by_milestone_spec.rb
+++ b/spec/features/merge_requests/filter_by_milestone_spec.rb
@@ -21,7 +21,7 @@ feature 'Merge Request filtering by Milestone', feature: true do
end
context 'filters by upcoming milestone', js: true do
- it 'should not show issues with no expiry' do
+ it 'does not show issues with no expiry' do
create(:merge_request, :with_diffs, source_project: project)
create(:merge_request, :simple, source_project: project, milestone: milestone)
@@ -31,7 +31,7 @@ feature 'Merge Request filtering by Milestone', feature: true do
expect(page).to have_css('.merge-request', count: 0)
end
- it 'should show issues in future' do
+ it 'shows issues in future' do
milestone = create(:milestone, project: project, due_date: Date.tomorrow)
create(:merge_request, :with_diffs, source_project: project)
create(:merge_request, :simple, source_project: project, milestone: milestone)
@@ -42,7 +42,7 @@ feature 'Merge Request filtering by Milestone', feature: true do
expect(page).to have_css('.merge-request', count: 1)
end
- it 'should not show issues in past' do
+ it 'does not show issues in past' do
milestone = create(:milestone, project: project, due_date: Date.yesterday)
create(:merge_request, :with_diffs, source_project: project)
create(:merge_request, :simple, source_project: project, milestone: milestone)
diff --git a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb
index 96f7b8c9932..60bc07bd1a0 100644
--- a/spec/features/merge_requests/merge_when_build_succeeds_spec.rb
+++ b/spec/features/merge_requests/merge_when_build_succeeds_spec.rb
@@ -73,7 +73,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
end
context 'Build is not active' do
- it "should not allow for enabling" do
+ it "does not allow for enabling" do
visit_merge_request(merge_request)
expect(page).not_to have_link "Merge When Build Succeeds"
end
diff --git a/spec/features/milestone_spec.rb b/spec/features/milestone_spec.rb
index c2c7acff3e8..c43661e5681 100644
--- a/spec/features/milestone_spec.rb
+++ b/spec/features/milestone_spec.rb
@@ -13,7 +13,7 @@ feature 'Milestone', feature: true do
end
feature 'Create a milestone' do
- scenario 'should show an informative message for a new issue' do
+ scenario 'shows an informative message for a new issue' do
visit new_namespace_project_milestone_path(project.namespace, project)
page.within '.milestone-form' do
fill_in "milestone_title", with: '8.7'
@@ -25,7 +25,7 @@ feature 'Milestone', feature: true do
end
feature 'Open a milestone with closed issues' do
- scenario 'should show an informative message' do
+ scenario 'shows an informative message' do
create(:issue, title: "Bugfix1", project: project, milestone: milestone, state: "closed")
visit namespace_project_milestone_path(project.namespace, project, milestone)
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index 0b38c413f44..7a9edbbe339 100644
--- a/spec/features/notes_on_merge_requests_spec.rb
+++ b/spec/features/notes_on_merge_requests_spec.rb
@@ -23,7 +23,7 @@ describe 'Comments', feature: true do
subject { page }
describe 'the note form' do
- it 'should be valid' do
+ it 'is valid' do
is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
expect(find('.js-main-target-form input[type=submit]').value).
to eq('Comment')
@@ -39,7 +39,7 @@ describe 'Comments', feature: true do
end
end
- it 'should have enable submit button and preview button' do
+ it 'has enable submit button and preview button' do
page.within('.js-main-target-form') do
expect(page).not_to have_css('.js-comment-button[disabled]')
expect(page).to have_css('.js-md-preview-button', visible: true)
@@ -57,7 +57,7 @@ describe 'Comments', feature: true do
end
end
- it 'should be added and form reset' do
+ it 'is added and form reset' do
is_expected.to have_content('This is awsome!')
page.within('.js-main-target-form') do
expect(page).to have_no_field('note[note]', with: 'This is awesome!')
@@ -70,7 +70,7 @@ describe 'Comments', feature: true do
end
describe 'when editing a note', js: true do
- it 'should contain the hidden edit form' do
+ it 'contains the hidden edit form' do
page.within("#note_#{note.id}") do
is_expected.to have_css('.note-edit-form', visible: false)
end
@@ -82,7 +82,7 @@ describe 'Comments', feature: true do
find(".js-note-edit").click
end
- it 'should show the note edit form and hide the note body' do
+ it 'shows the note edit form and hide the note body' do
page.within("#note_#{note.id}") do
expect(find('.current-note-edit-form', visible: true)).to be_visible
expect(find('.note-edit-form', visible: true)).to be_visible
@@ -234,7 +234,7 @@ describe 'Comments', feature: true do
end
end
- it 'should be added as discussion' do
+ it 'adds as discussion' do
is_expected.to have_content('Another comment on line 10')
is_expected.to have_css('.notes_holder')
is_expected.to have_css('.notes_holder .note', count: 1)
diff --git a/spec/features/participants_autocomplete_spec.rb b/spec/features/participants_autocomplete_spec.rb
index c7c00a3266a..a78a1c9c890 100644
--- a/spec/features/participants_autocomplete_spec.rb
+++ b/spec/features/participants_autocomplete_spec.rb
@@ -12,17 +12,17 @@ feature 'Member autocomplete', feature: true do
end
shared_examples "open suggestions" do
- it 'suggestions are displayed' do
+ it 'displays suggestions' do
expect(page).to have_selector('.atwho-view', visible: true)
end
- it 'author is suggested' do
+ it 'suggests author' do
page.within('.atwho-view', visible: true) do
expect(page).to have_content(author.username)
end
end
- it 'participant is suggested' do
+ it 'suggests participant' do
page.within('.atwho-view', visible: true) do
expect(page).to have_content(participant.username)
end
diff --git a/spec/features/pipelines_spec.rb b/spec/features/pipelines_spec.rb
index fb69876f98c..1256f73196b 100644
--- a/spec/features/pipelines_spec.rb
+++ b/spec/features/pipelines_spec.rb
@@ -82,11 +82,11 @@ describe "Pipelines" do
before { visit namespace_project_pipelines_path(project.namespace, project) }
- it 'not be cancelable' do
+ it 'is not cancelable' do
expect(page).not_to have_link('Cancel')
end
- it 'pipeline is running' do
+ it 'has pipeline running' do
expect(page).to have_selector('.ci-running')
end
end
@@ -96,11 +96,11 @@ describe "Pipelines" do
before { visit namespace_project_pipelines_path(project.namespace, project) }
- it 'not be retryable' do
+ it 'is not retryable' do
expect(page).not_to have_link('Retry')
end
- it 'pipeline is failed' do
+ it 'has failed pipeline' do
expect(page).to have_selector('.ci-failed')
end
end
@@ -147,7 +147,7 @@ describe "Pipelines" do
before { visit namespace_project_pipeline_path(project.namespace, project, pipeline) }
- it 'showing a list of builds' do
+ it 'shows a list of builds' do
expect(page).to have_content('Test')
expect(page).to have_content(@success.id)
expect(page).to have_content('Deploy')
diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb
index c80253fead8..c3d8c349ca4 100644
--- a/spec/features/profile_spec.rb
+++ b/spec/features/profile_spec.rb
@@ -15,7 +15,7 @@ describe 'Profile account page', feature: true do
it { expect(page).to have_content('Remove account') }
- it 'should delete the account' do
+ it 'deletes the account' do
expect { click_link 'Delete account' }.to change { User.count }.by(-1)
expect(current_path).to eq(new_user_session_path)
end
@@ -27,7 +27,7 @@ describe 'Profile account page', feature: true do
visit profile_account_path
end
- it 'should not have option to remove account' do
+ it 'does not have option to remove account' do
expect(page).not_to have_content('Remove account')
expect(current_path).to eq(profile_account_path)
end
diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb
new file mode 100644
index 00000000000..4cbdd89d46f
--- /dev/null
+++ b/spec/features/profiles/password_spec.rb
@@ -0,0 +1,45 @@
+require 'spec_helper'
+
+describe 'Profile > Password', feature: true do
+ let(:user) { create(:user, password_automatically_set: true) }
+
+ before do
+ login_as(user)
+ visit edit_profile_password_path
+ end
+
+ def fill_passwords(password, confirmation)
+ fill_in 'New password', with: password
+ fill_in 'Password confirmation', with: confirmation
+
+ click_button 'Save password'
+ end
+
+ context 'User with password automatically set' do
+ describe 'User puts different passwords in the field and in the confirmation' do
+ it 'shows an error message' do
+ fill_passwords('mypassword', 'mypassword2')
+
+ page.within('.alert-danger') do
+ expect(page).to have_content("Password confirmation doesn't match Password")
+ end
+ end
+
+ it 'does not contains the current password field after an error' do
+ fill_passwords('mypassword', 'mypassword2')
+
+ expect(page).to have_no_field('user[current_password]')
+ end
+ end
+
+ describe 'User puts the same passwords in the field and in the confirmation' do
+ it 'shows a success message' do
+ fill_passwords('mypassword', 'mypassword')
+
+ page.within('.flash-notice') do
+ expect(page).to have_content('Password was successfully updated. Please login with it')
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb
index 98ba93b4036..cb7495da8eb 100644
--- a/spec/features/projects/labels/update_prioritization_spec.rb
+++ b/spec/features/projects/labels/update_prioritization_spec.rb
@@ -87,7 +87,7 @@ feature 'Prioritize labels', feature: true do
end
context 'as a guest' do
- it 'can not prioritize labels' do
+ it 'does not prioritize labels' do
user = create(:user)
guest = create(:user)
project = create(:project, name: 'test', namespace: user.namespace)
@@ -102,7 +102,7 @@ feature 'Prioritize labels', feature: true do
end
context 'as a non signed in user' do
- it 'can not prioritize labels' do
+ it 'does not prioritize labels' do
user = create(:user)
project = create(:project, name: 'test', namespace: user.namespace)
diff --git a/spec/features/projects/ref_switcher_spec.rb b/spec/features/projects/ref_switcher_spec.rb
new file mode 100644
index 00000000000..b3ba40b35af
--- /dev/null
+++ b/spec/features/projects/ref_switcher_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+feature 'Ref switcher', feature: true, js: true do
+ include WaitForAjax
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :public) }
+
+ before do
+ project.team << [user, :master]
+ login_as(user)
+ visit namespace_project_tree_path(project.namespace, project, 'master')
+ end
+
+ it 'allow user to change ref by enter key' do
+ click_button 'master'
+ wait_for_ajax
+
+ page.within '.project-refs-form' do
+ input = find('input[type="search"]')
+ input.set 'expand'
+
+ input.native.send_keys :down
+ input.native.send_keys :down
+ input.native.send_keys :enter
+
+ expect(page).to have_content 'expand-collapse-files'
+ end
+ end
+end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 6fa8298d489..1b14c66fe28 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -44,7 +44,7 @@ feature 'Project', feature: true do
visit edit_namespace_project_path(project.namespace, project)
end
- it 'should remove fork' do
+ it 'removes fork' do
expect(page).to have_content 'Remove fork relationship'
remove_with_confirm('Remove fork relationship', project.path)
@@ -65,7 +65,7 @@ feature 'Project', feature: true do
visit edit_namespace_project_path(project.namespace, project)
end
- it 'should remove project' do
+ it 'removes project' do
expect { remove_with_confirm('Remove project', project.path) }.to change {Project.count}.by(-1)
end
end
@@ -82,7 +82,7 @@ feature 'Project', feature: true do
visit namespace_project_path(project.namespace, project)
end
- it 'click toggle and show dropdown', js: true do
+ it 'clicks toggle and shows dropdown', js: true do
find('.js-projects-dropdown-toggle').click
expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 1)
end
@@ -102,7 +102,7 @@ feature 'Project', feature: true do
visit namespace_project_issue_path(project.namespace, project, issue)
end
- it 'click toggle and show dropdown' do
+ it 'clicks toggle and shows dropdown' do
find('.js-projects-dropdown-toggle').click
expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 2)
diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb
index 57734b33a44..3499460c84d 100644
--- a/spec/features/protected_branches_spec.rb
+++ b/spec/features/protected_branches_spec.rb
@@ -11,7 +11,7 @@ feature 'Projected Branches', feature: true, js: true do
def set_protected_branch_name(branch_name)
find(".js-protected-branch-select").click
find(".dropdown-input-field").set(branch_name)
- click_on "Create Protected Branch: #{branch_name}"
+ click_on("Create wildcard #{branch_name}")
end
describe "explicit protected branches" do
@@ -90,7 +90,7 @@ feature 'Projected Branches', feature: true, js: true do
visit namespace_project_protected_branches_path(project.namespace, project)
set_protected_branch_name('master')
within('.new_protected_branch') do
- find(".allowed-to-push").click
+ find(".js-allowed-to-push").click
within(".dropdown.open .dropdown-menu") { click_on access_type_name }
end
click_on "Protect"
@@ -107,8 +107,8 @@ feature 'Projected Branches', feature: true, js: true do
expect(ProtectedBranch.count).to eq(1)
within(".protected-branches-list") do
- find(".allowed-to-push").click
- within('.dropdown-menu.push') { click_on access_type_name }
+ find(".js-allowed-to-push").click
+ within('.js-allowed-to-push-container') { click_on access_type_name }
end
wait_for_ajax
@@ -121,7 +121,7 @@ feature 'Projected Branches', feature: true, js: true do
visit namespace_project_protected_branches_path(project.namespace, project)
set_protected_branch_name('master')
within('.new_protected_branch') do
- find(".allowed-to-merge").click
+ find(".js-allowed-to-merge").click
within(".dropdown.open .dropdown-menu") { click_on access_type_name }
end
click_on "Protect"
@@ -138,8 +138,8 @@ feature 'Projected Branches', feature: true, js: true do
expect(ProtectedBranch.count).to eq(1)
within(".protected-branches-list") do
- find(".allowed-to-merge").click
- within('.dropdown-menu.merge') { click_on access_type_name }
+ find(".js-allowed-to-merge").click
+ within('.js-allowed-to-merge-container') { click_on access_type_name }
end
wait_for_ajax
diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb
index 09f70cd3b00..b7a25d80fec 100644
--- a/spec/features/search_spec.rb
+++ b/spec/features/search_spec.rb
@@ -12,7 +12,7 @@ describe "Search", feature: true do
visit search_path
end
- it 'top right search form is not present' do
+ it 'does not show top right search form' do
expect(page).not_to have_selector('.search')
end
@@ -76,16 +76,16 @@ describe "Search", feature: true do
visit namespace_project_path(project.namespace, project)
end
- it 'top right search form is present' do
+ it 'shows top right search form' do
expect(page).to have_selector('#search')
end
- it 'top right search form contains location badge' do
+ it 'contains location badge in top right search form' do
expect(page).to have_selector('.has-location-badge')
end
context 'clicking the search field', js: true do
- it 'should show category search dropdown' do
+ it 'shows category search dropdown' do
page.find('#search').click
expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i)
@@ -97,7 +97,7 @@ describe "Search", feature: true do
page.find('#search').click
end
- it 'should take user to her issues page when issues assigned is clicked' do
+ it 'takes user to her issues page when issues assigned is clicked' do
find('.dropdown-menu').click_link 'Issues assigned to me'
sleep 2
@@ -105,7 +105,7 @@ describe "Search", feature: true do
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
end
- it 'should take user to her issues page when issues authored is clicked' do
+ it 'takes user to her issues page when issues authored is clicked' do
find('.dropdown-menu').click_link "Issues I've created"
sleep 2
@@ -113,7 +113,7 @@ describe "Search", feature: true do
expect(find('.js-author-search .dropdown-toggle-text')).to have_content(user.name)
end
- it 'should take user to her MR page when MR assigned is clicked' do
+ it 'takes user to her MR page when MR assigned is clicked' do
find('.dropdown-menu').click_link 'Merge requests assigned to me'
sleep 2
@@ -121,7 +121,7 @@ describe "Search", feature: true do
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
end
- it 'should take user to her MR page when MR authored is clicked' do
+ it 'takes user to her MR page when MR authored is clicked' do
find('.dropdown-menu').click_link "Merge requests I've created"
sleep 2
@@ -137,7 +137,7 @@ describe "Search", feature: true do
end
end
- it 'should not display the category search dropdown' do
+ it 'does not display the category search dropdown' do
expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i)
end
end
diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb
index 0bdb1628c74..0342f4f1d97 100644
--- a/spec/features/todos/todos_spec.rb
+++ b/spec/features/todos/todos_spec.rb
@@ -24,7 +24,7 @@ describe 'Dashboard Todos', feature: true do
visit dashboard_todos_path
end
- it 'todo is present' do
+ it 'has todo present' do
expect(page).to have_selector('.todos-list .todo', count: 1)
end
diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb
index a2b8f7b6931..61f2bc61e0c 100644
--- a/spec/features/variables_spec.rb
+++ b/spec/features/variables_spec.rb
@@ -13,13 +13,13 @@ describe 'Project variables', js: true do
visit namespace_project_variables_path(project.namespace, project)
end
- it 'should show list of variables' do
+ it 'shows list of variables' do
page.within('.variables-table') do
expect(page).to have_content(variable.key)
end
end
- it 'should add new variable' do
+ it 'adds new variable' do
fill_in('variable_key', with: 'key')
fill_in('variable_value', with: 'key value')
click_button('Add new variable')
@@ -29,7 +29,7 @@ describe 'Project variables', js: true do
end
end
- it 'should delete variable' do
+ it 'deletes variable' do
page.within('.variables-table') do
find('.btn-variable-delete').click
end
@@ -37,7 +37,7 @@ describe 'Project variables', js: true do
expect(page).not_to have_selector('variables-table')
end
- it 'should edit variable' do
+ it 'edits variable' do
page.within('.variables-table') do
find('.btn-variable-edit').click
end
diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb
index bc385fd0d69..535aabfc18d 100644
--- a/spec/finders/merge_requests_finder_spec.rb
+++ b/spec/finders/merge_requests_finder_spec.rb
@@ -18,13 +18,13 @@ describe MergeRequestsFinder do
end
describe "#execute" do
- it 'should filter by scope' do
+ it 'filters by scope' do
params = { scope: 'authored', state: 'opened' }
merge_requests = MergeRequestsFinder.new(user, params).execute
expect(merge_requests.size).to eq(2)
end
- it 'should filter by project' do
+ it 'filters by project' do
params = { project_id: project1.id, scope: 'authored', state: 'opened' }
merge_requests = MergeRequestsFinder.new(user, params).execute
expect(merge_requests.size).to eq(1)
diff --git a/spec/finders/notes_finder_spec.rb b/spec/finders/notes_finder_spec.rb
index 8db897b1646..7c6860372cc 100644
--- a/spec/finders/notes_finder_spec.rb
+++ b/spec/finders/notes_finder_spec.rb
@@ -19,12 +19,12 @@ describe NotesFinder do
note2
end
- it 'should find all notes' do
+ it 'finds all notes' do
notes = NotesFinder.new.execute(project, user, params)
expect(notes.size).to eq(2)
end
- it 'should raise an exception for an invalid target_type' do
+ it 'raises an exception for an invalid target_type' do
params.merge!(target_type: 'invalid')
expect { NotesFinder.new.execute(project, user, params) }.to raise_error('invalid target_type')
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index bb28866f010..73f5470cf35 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -54,7 +54,7 @@ describe ApplicationHelper do
describe 'project_icon' do
let(:avatar_file_path) { File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') }
- it 'should return an url for the avatar' do
+ it 'returns an url for the avatar' do
project = create(:project, avatar: File.open(avatar_file_path))
avatar_url = "http://localhost/uploads/project/avatar/#{project.id}/banana_sample.gif"
@@ -62,7 +62,7 @@ describe ApplicationHelper do
to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />"
end
- it 'should give uploaded icon when present' do
+ it 'gives uploaded icon when present' do
project = create(:project)
allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true)
@@ -76,14 +76,14 @@ describe ApplicationHelper do
describe 'avatar_icon' do
let(:avatar_file_path) { File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') }
- it 'should return an url for the avatar' do
+ it 'returns an url for the avatar' do
user = create(:user, avatar: File.open(avatar_file_path))
expect(helper.avatar_icon(user.email).to_s).
to match("/uploads/user/avatar/#{user.id}/banana_sample.gif")
end
- it 'should return an url for the avatar with relative url' do
+ it 'returns an url for the avatar with relative url' do
stub_config_setting(relative_url_root: '/gitlab')
# Must be stubbed after the stub above, and separately
stub_config_setting(url: Settings.send(:build_gitlab_url))
@@ -94,14 +94,14 @@ describe ApplicationHelper do
to match("/gitlab/uploads/user/avatar/#{user.id}/banana_sample.gif")
end
- it 'should call gravatar_icon when no User exists with the given email' do
+ it 'calls gravatar_icon when no User exists with the given email' do
expect(helper).to receive(:gravatar_icon).with('foo@example.com', 20, 2)
helper.avatar_icon('foo@example.com', 20, 2)
end
describe 'using a User' do
- it 'should return an URL for the avatar' do
+ it 'returns an URL for the avatar' do
user = create(:user, avatar: File.open(avatar_file_path))
expect(helper.avatar_icon(user).to_s).
@@ -146,7 +146,7 @@ describe ApplicationHelper do
to match('https://secure.gravatar.com')
end
- it 'should return custom gravatar path when gravatar_url is set' do
+ it 'returns custom gravatar path when gravatar_url is set' do
stub_gravatar_setting(plain_url: 'http://example.local/?s=%{size}&hash=%{hash}')
expect(gravatar_icon(user_email, 20)).
@@ -218,12 +218,12 @@ describe ApplicationHelper do
end
it 'includes a default js-timeago class' do
- expect(element.attr('class')).to eq 'time_ago js-timeago js-timeago-pending'
+ expect(element.attr('class')).to eq 'js-timeago js-timeago-pending'
end
it 'accepts a custom html_class' do
expect(element(html_class: 'custom_class').attr('class')).
- to eq 'custom_class js-timeago js-timeago-pending'
+ to eq 'js-timeago custom_class js-timeago-pending'
end
it 'accepts a custom tooltip placement' do
@@ -244,6 +244,19 @@ describe ApplicationHelper do
it 'converts to Time' do
expect { helper.time_ago_with_tooltip(Date.today) }.not_to raise_error
end
+
+ it 'add class for the short format and includes inline script' do
+ timeago_element = element(short_format: 'short')
+ expect(timeago_element.attr('class')).to eq 'js-short-timeago js-timeago-pending'
+ script_element = timeago_element.next_element
+ expect(script_element.name).to eq 'script'
+ end
+
+ it 'add class for the short format and does not include inline script' do
+ timeago_element = element(short_format: 'short', skip_js: true)
+ expect(timeago_element.attr('class')).to eq 'js-short-timeago'
+ expect(timeago_element.next_element).to eq nil
+ end
end
describe 'render_markup' do
@@ -253,19 +266,19 @@ describe ApplicationHelper do
allow(helper).to receive(:current_user).and_return(user)
end
- it 'should preserve encoding' do
+ it 'preserves encoding' do
expect(content.encoding.name).to eq('UTF-8')
expect(helper.render_markup('foo.rst', content).encoding.name).to eq('UTF-8')
end
- it "should delegate to #markdown when file name corresponds to Markdown" do
+ it "delegates to #markdown when file name corresponds to Markdown" do
expect(helper).to receive(:gitlab_markdown?).with('foo.md').and_return(true)
expect(helper).to receive(:markdown).and_return('NOEL')
expect(helper.render_markup('foo.md', content)).to eq('NOEL')
end
- it "should delegate to #asciidoc when file name corresponds to AsciiDoc" do
+ it "delegates to #asciidoc when file name corresponds to AsciiDoc" do
expect(helper).to receive(:asciidoc?).with('foo.adoc').and_return(true)
expect(helper).to receive(:asciidoc).and_return('NOEL')
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb
index b2d6d59b1ee..94972eed945 100644
--- a/spec/helpers/blob_helper_spec.rb
+++ b/spec/helpers/blob_helper_spec.rb
@@ -17,19 +17,19 @@ describe BlobHelper do
end
describe '#highlight' do
- it 'should return plaintext for unknown lexer context' do
+ it 'returns plaintext for unknown lexer context' do
result = helper.highlight(blob_name, no_context_content)
expect(result).to eq(%[<pre class="code highlight"><code><span id="LC1" class="line">:type "assem"))</span></code></pre>])
end
- it 'should highlight single block' do
+ it 'highlights single block' do
expected = %Q[<pre class="code highlight"><code><span id="LC1" class="line"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span>
<span id="LC2" class="line"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">))</span></span></code></pre>]
expect(helper.highlight(blob_name, blob_content)).to eq(expected)
end
- it 'should highlight multi-line comments' do
+ it 'highlights multi-line comments' do
result = helper.highlight(blob_name, multiline_content)
html = Nokogiri::HTML(result)
lines = html.search('.s')
@@ -49,7 +49,7 @@ describe BlobHelper do
<span id="LC4" class="line"> ddd</span></code></pre>)
end
- it 'should highlight each line properly' do
+ it 'highlights each line properly' do
result = helper.highlight(blob_name, blob_content)
expect(result).to eq(expected)
end
@@ -62,7 +62,7 @@ describe BlobHelper do
let(:expected_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'sanitized.svg') }
let(:expected) { open(expected_svg_path).read }
- it 'should retain essential elements' do
+ it 'retains essential elements' do
blob = OpenStruct.new(data: data)
expect(sanitize_svg(blob).data).to eq(expected)
end
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index 4949280d641..9c7c79f57c6 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -15,76 +15,56 @@ describe DiffHelper do
it 'returns a valid value when cookie is set' do
helper.request.cookies[:diff_view] = 'parallel'
- expect(helper.diff_view).to eq 'parallel'
+ expect(helper.diff_view).to eq :parallel
end
it 'returns a default value when cookie is invalid' do
helper.request.cookies[:diff_view] = 'invalid'
- expect(helper.diff_view).to eq 'inline'
+ expect(helper.diff_view).to eq :inline
end
it 'returns a default value when cookie is nil' do
expect(helper.request.cookies).to be_empty
- expect(helper.diff_view).to eq 'inline'
+ expect(helper.diff_view).to eq :inline
end
end
-
+
describe 'diff_options' do
- it 'should return no collapse false' do
+ it 'returns no collapse false' do
expect(diff_options).to include(no_collapse: false)
end
- it 'should return no collapse true if expand_all_diffs' do
+ it 'returns no collapse true if expand_all_diffs' do
allow(controller).to receive(:params) { { expand_all_diffs: true } }
expect(diff_options).to include(no_collapse: true)
end
- it 'should return no collapse true if action name diff_for_path' do
+ it 'returns no collapse true if action name diff_for_path' do
allow(controller).to receive(:action_name) { 'diff_for_path' }
expect(diff_options).to include(no_collapse: true)
end
- it 'should return paths if action name diff_for_path and param old path' do
+ it 'returns paths if action name diff_for_path and param old path' do
allow(controller).to receive(:params) { { old_path: 'lib/wadus.rb' } }
allow(controller).to receive(:action_name) { 'diff_for_path' }
expect(diff_options[:paths]).to include('lib/wadus.rb')
end
- it 'should return paths if action name diff_for_path and param new path' do
+ it 'returns paths if action name diff_for_path and param new path' do
allow(controller).to receive(:params) { { new_path: 'lib/wadus.rb' } }
allow(controller).to receive(:action_name) { 'diff_for_path' }
expect(diff_options[:paths]).to include('lib/wadus.rb')
end
end
- describe 'unfold_bottom_class' do
- it 'should return empty string when bottom line shouldnt be unfolded' do
- expect(unfold_bottom_class(false)).to eq('')
- end
-
- it 'should return js class when bottom lines should be unfolded' do
- expect(unfold_bottom_class(true)).to include('js-unfold-bottom')
- end
- end
-
- describe 'unfold_class' do
- it 'returns empty on false' do
- expect(unfold_class(false)).to eq('')
- end
-
- it 'returns a class on true' do
- expect(unfold_class(true)).to eq('unfold js-unfold')
- end
- end
-
describe '#diff_line_content' do
- it 'should return non breaking space when line is empty' do
+ it 'returns non breaking space when line is empty' do
expect(diff_line_content(nil)).to eq(' &nbsp;')
end
- it 'should return the line itself' do
+ it 'returns the line itself' do
expect(diff_line_content(diff_file.diff_lines.first.text)).
to eq('@@ -6,12 +6,18 @@ module Popen')
expect(diff_line_content(diff_file.diff_lines.first.type)).to eq('match')
@@ -105,4 +85,56 @@ describe DiffHelper do
expect(marked_new_line).to be_html_safe
end
end
+
+ describe "#diff_match_line" do
+ let(:old_pos) { 40 }
+ let(:new_pos) { 50 }
+ let(:text) { 'some_text' }
+
+ it "should generate foldable top match line for inline view with empty text by default" do
+ output = diff_match_line old_pos, new_pos
+
+ expect(output).to be_html_safe
+ expect(output).to have_css "td:nth-child(1):not(.js-unfold-bottom).diff-line-num.unfold.js-unfold.old_line[data-linenumber='#{old_pos}']", text: '...'
+ expect(output).to have_css "td:nth-child(2):not(.js-unfold-bottom).diff-line-num.unfold.js-unfold.new_line[data-linenumber='#{new_pos}']", text: '...'
+ expect(output).to have_css 'td:nth-child(3):not(.parallel).line_content.match', text: ''
+ end
+
+ it "should allow to define text and bottom option" do
+ output = diff_match_line old_pos, new_pos, text: text, bottom: true
+
+ expect(output).to be_html_safe
+ expect(output).to have_css "td:nth-child(1).diff-line-num.unfold.js-unfold.js-unfold-bottom.old_line[data-linenumber='#{old_pos}']", text: '...'
+ expect(output).to have_css "td:nth-child(2).diff-line-num.unfold.js-unfold.js-unfold-bottom.new_line[data-linenumber='#{new_pos}']", text: '...'
+ expect(output).to have_css 'td:nth-child(3):not(.parallel).line_content.match', text: text
+ end
+
+ it "should generate match line for parallel view" do
+ output = diff_match_line old_pos, new_pos, text: text, view: :parallel
+
+ expect(output).to be_html_safe
+ expect(output).to have_css "td:nth-child(1):not(.js-unfold-bottom).diff-line-num.unfold.js-unfold.old_line[data-linenumber='#{old_pos}']", text: '...'
+ expect(output).to have_css 'td:nth-child(2).line_content.match.parallel', text: text
+ expect(output).to have_css "td:nth-child(3):not(.js-unfold-bottom).diff-line-num.unfold.js-unfold.new_line[data-linenumber='#{new_pos}']", text: '...'
+ expect(output).to have_css 'td:nth-child(4).line_content.match.parallel', text: text
+ end
+
+ it "should allow to generate only left match line for parallel view" do
+ output = diff_match_line old_pos, nil, text: text, view: :parallel
+
+ expect(output).to be_html_safe
+ expect(output).to have_css "td:nth-child(1):not(.js-unfold-bottom).diff-line-num.unfold.js-unfold.old_line[data-linenumber='#{old_pos}']", text: '...'
+ expect(output).to have_css 'td:nth-child(2).line_content.match.parallel', text: text
+ expect(output).not_to have_css 'td:nth-child(3)'
+ end
+
+ it "should allow to generate only right match line for parallel view" do
+ output = diff_match_line nil, new_pos, text: text, view: :parallel
+
+ expect(output).to be_html_safe
+ expect(output).to have_css "td:nth-child(1):not(.js-unfold-bottom).diff-line-num.unfold.js-unfold.new_line[data-linenumber='#{new_pos}']", text: '...'
+ expect(output).to have_css 'td:nth-child(2).line_content.match.parallel', text: text
+ expect(output).not_to have_css 'td:nth-child(3)'
+ end
+ end
end
diff --git a/spec/helpers/emails_helper_spec.rb b/spec/helpers/emails_helper_spec.rb
index 7a3e38d7e63..3223556e1d3 100644
--- a/spec/helpers/emails_helper_spec.rb
+++ b/spec/helpers/emails_helper_spec.rb
@@ -8,37 +8,37 @@ describe EmailsHelper do
end
context 'when time limit is less than 2 hours' do
- it 'should display the time in hours using a singular unit' do
+ it 'displays the time in hours using a singular unit' do
validate_time_string(1.hour, '1 hour')
end
end
context 'when time limit is 2 or more hours' do
- it 'should display the time in hours using a plural unit' do
+ it 'displays the time in hours using a plural unit' do
validate_time_string(2.hours, '2 hours')
end
end
context 'when time limit contains fractions of an hour' do
- it 'should round down to the nearest hour' do
+ it 'rounds down to the nearest hour' do
validate_time_string(96.minutes, '1 hour')
end
end
context 'when time limit is 24 or more hours' do
- it 'should display the time in days using a singular unit' do
+ it 'displays the time in days using a singular unit' do
validate_time_string(24.hours, '1 day')
end
end
context 'when time limit is 2 or more days' do
- it 'should display the time in days using a plural unit' do
+ it 'displays the time in days using a plural unit' do
validate_time_string(2.days, '2 days')
end
end
context 'when time limit contains fractions of a day' do
- it 'should round down to the nearest day' do
+ it 'rounds down to the nearest day' do
validate_time_string(57.hours, '2 days')
end
end
diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb
index 6b5e3d93d48..022aba0c0d0 100644
--- a/spec/helpers/events_helper_spec.rb
+++ b/spec/helpers/events_helper_spec.rb
@@ -6,34 +6,34 @@ describe EventsHelper do
allow(helper).to receive(:current_user).and_return(double)
end
- it 'should display one line of plain text without alteration' do
+ it 'displays one line of plain text without alteration' do
input = 'A short, plain note'
expect(helper.event_note(input)).to match(input)
expect(helper.event_note(input)).not_to match(/\.\.\.\z/)
end
- it 'should display inline code' do
+ it 'displays inline code' do
input = 'A note with `inline code`'
expected = 'A note with <code>inline code</code>'
expect(helper.event_note(input)).to match(expected)
end
- it 'should truncate a note with multiple paragraphs' do
+ it 'truncates a note with multiple paragraphs' do
input = "Paragraph 1\n\nParagraph 2"
expected = 'Paragraph 1...'
expect(helper.event_note(input)).to match(expected)
end
- it 'should display the first line of a code block' do
+ it 'displays the first line of a code block' do
input = "```\nCode block\nwith two lines\n```"
expected = %r{<pre.+><code>Code block\.\.\.</code></pre>}
expect(helper.event_note(input)).to match(expected)
end
- it 'should truncate a single long line of text' do
+ it 'truncates a single long line of text' do
text = 'The quick brown fox jumped over the lazy dog twice' # 50 chars
input = text * 4
expected = (text * 2).sub(/.{3}/, '...')
@@ -41,7 +41,7 @@ describe EventsHelper do
expect(helper.event_note(input)).to match(expected)
end
- it 'should preserve a link href when link text is truncated' do
+ it 'preserves a link href when link text is truncated' do
text = 'The quick brown fox jumped over the lazy dog' # 44 chars
input = "#{text}#{text}#{text} " # 133 chars
link_url = 'http://example.com/foo/bar/baz' # 30 chars
@@ -52,7 +52,7 @@ describe EventsHelper do
expect(helper.event_note(input)).to match(expected_link_text)
end
- it 'should preserve code color scheme' do
+ it 'preserves code color scheme' do
input = "```ruby\ndef test\n 'hello world'\nend\n```"
expected = '<pre class="code highlight js-syntax-highlight ruby">' \
"<code><span class=\"k\">def</span> <span class=\"nf\">test</span>\n" \
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index ade5c3b02d9..5368e5fab06 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -26,17 +26,17 @@ describe GitlabMarkdownHelper do
describe "referencing multiple objects" do
let(:actual) { "#{merge_request.to_reference} -> #{commit.to_reference} -> #{issue.to_reference}" }
- it "should link to the merge request" do
+ it "links to the merge request" do
expected = namespace_project_merge_request_path(project.namespace, project, merge_request)
expect(helper.markdown(actual)).to match(expected)
end
- it "should link to the commit" do
+ it "links to the commit" do
expected = namespace_project_commit_path(project.namespace, project, commit)
expect(helper.markdown(actual)).to match(expected)
end
- it "should link to the issue" do
+ it "links to the issue" do
expected = namespace_project_issue_path(project.namespace, project, issue)
expect(helper.markdown(actual)).to match(expected)
end
@@ -47,7 +47,7 @@ describe GitlabMarkdownHelper do
let(:second_project) { create(:project, :public) }
let(:second_issue) { create(:issue, project: second_project) }
- it 'should link to the issue' do
+ it 'links to the issue' do
expected = namespace_project_issue_path(second_project.namespace, second_project, second_issue)
expect(markdown(actual, project: second_project)).to match(expected)
end
@@ -58,7 +58,7 @@ describe GitlabMarkdownHelper do
let(:commit_path) { namespace_project_commit_path(project.namespace, project, commit) }
let(:issues) { create_list(:issue, 2, project: project) }
- it 'should handle references nested in links with all the text' do
+ it 'handles references nested in links with all the text' do
actual = helper.link_to_gfm("This should finally fix #{issues[0].to_reference} and #{issues[1].to_reference} for real", commit_path)
doc = Nokogiri::HTML.parse(actual)
@@ -88,7 +88,7 @@ describe GitlabMarkdownHelper do
expect(doc.css('a')[4].text).to eq ' for real'
end
- it 'should forward HTML options' do
+ it 'forwards HTML options' do
actual = helper.link_to_gfm("Fixed in #{commit.id}", commit_path, class: 'foo')
doc = Nokogiri::HTML.parse(actual)
@@ -110,7 +110,7 @@ describe GitlabMarkdownHelper do
expect(act).to eq %Q(<a href="/foo">#{issues[0].to_reference}</a>)
end
- it 'should replace commit message with emoji to link' do
+ it 'replaces commit message with emoji to link' do
actual = link_to_gfm(':book:Book', '/foo')
expect(actual).
to eq %Q(<img class="emoji" title=":book:" alt=":book:" src="http://localhost/assets/1F4D6.png" height="20" width="20" align="absmiddle"><a href="/foo">Book</a>)
@@ -125,7 +125,7 @@ describe GitlabMarkdownHelper do
helper.instance_variable_set(:@project_wiki, @wiki)
end
- it "should use Wiki pipeline for markdown files" do
+ it "uses Wiki pipeline for markdown files" do
allow(@wiki).to receive(:format).and_return(:markdown)
expect(helper).to receive(:markdown).with('wiki content', pipeline: :wiki, project_wiki: @wiki, page_slug: "nested/page")
@@ -133,7 +133,7 @@ describe GitlabMarkdownHelper do
helper.render_wiki_content(@wiki)
end
- it "should use Asciidoctor for asciidoc files" do
+ it "uses Asciidoctor for asciidoc files" do
allow(@wiki).to receive(:format).and_return(:asciidoc)
expect(helper).to receive(:asciidoc).with('wiki content')
@@ -141,7 +141,7 @@ describe GitlabMarkdownHelper do
helper.render_wiki_content(@wiki)
end
- it "should use the Gollum renderer for all other file types" do
+ it "uses the Gollum renderer for all other file types" do
allow(@wiki).to receive(:format).and_return(:rdoc)
formatted_content_stub = double('formatted_content')
expect(formatted_content_stub).to receive(:html_safe)
diff --git a/spec/helpers/graph_helper_spec.rb b/spec/helpers/graph_helper_spec.rb
index 4acf38771b7..51c49f0e587 100644
--- a/spec/helpers/graph_helper_spec.rb
+++ b/spec/helpers/graph_helper_spec.rb
@@ -6,7 +6,7 @@ describe GraphHelper do
let(:commit) { project.commit("master") }
let(:graph) { Network::Graph.new(project, 'master', commit, '') }
- it 'filter our refs used by GitLab' do
+ it 'filters our refs used by GitLab' do
allow(commit).to receive(:ref_names).and_return(['refs/merge-requests/abc', 'master', 'refs/tmp/xyz'])
self.instance_variable_set(:@graph, graph)
refs = get_refs(project.repository, commit)
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index 4ea90a80a92..0807534720a 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -4,7 +4,7 @@ describe GroupsHelper do
describe 'group_icon' do
avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
- it 'should return an url for the avatar' do
+ it 'returns an url for the avatar' do
group = create(:group)
group.avatar = File.open(avatar_file_path)
group.save!
@@ -12,7 +12,7 @@ describe GroupsHelper do
to match("/uploads/group/avatar/#{group.id}/banana_sample.gif")
end
- it 'should give default avatar_icon when no avatar is present' do
+ it 'gives default avatar_icon when no avatar is present' do
group = create(:group)
group.save!
expect(group_icon(group.path)).to match('group_avatar.png')
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 9ee46dd2508..5e4655dfc95 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -10,18 +10,19 @@ describe IssuesHelper do
let(:ext_expected) { issues_url.gsub(':id', issue.iid.to_s).gsub(':project_id', ext_project.id.to_s) }
let(:int_expected) { polymorphic_path([@project.namespace, project, issue]) }
- it "should return internal path if used internal tracker" do
+ it "returns internal path if used internal tracker" do
@project = project
+
expect(url_for_issue(issue.iid)).to match(int_expected)
end
- it "should return path to external tracker" do
+ it "returns path to external tracker" do
@project = ext_project
expect(url_for_issue(issue.iid)).to match(ext_expected)
end
- it "should return empty string if project nil" do
+ it "returns empty string if project nil" do
@project = nil
expect(url_for_issue(issue.iid)).to eq ""
@@ -45,7 +46,7 @@ describe IssuesHelper do
allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
- it "should return external path" do
+ it "returns external path" do
expect(url_for_issue(issue.iid)).to match(ext_expected)
end
end
diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb
index f782c153017..fb0ace73707 100644
--- a/spec/helpers/notes_helper_spec.rb
+++ b/spec/helpers/notes_helper_spec.rb
@@ -21,7 +21,7 @@ describe NotesHelper do
end
describe "#notes_max_access_for_users" do
- it 'return human access levels' do
+ it 'returns human access levels' do
expect(helper.note_max_access_for_user(owner_note)).to eq('Owner')
expect(helper.note_max_access_for_user(master_note)).to eq('Master')
expect(helper.note_max_access_for_user(reporter_note)).to eq('Reporter')
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index 601b6915e27..b0bb991539b 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -42,7 +42,7 @@ describe SearchHelper do
expect(search_autocomplete_opts(project.name).size).to eq(1)
end
- it "should not include the public group" do
+ it "does not include the public group" do
group = create(:group)
expect(search_autocomplete_opts(group.name).size).to eq(0)
end
diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb
index 10121759132..37ac6a2699d 100644
--- a/spec/helpers/submodule_helper_spec.rb
+++ b/spec/helpers/submodule_helper_spec.rb
@@ -17,35 +17,35 @@ describe SubmoduleHelper do
allow(Gitlab.config.gitlab).to receive(:protocol).and_return('http') # set this just to be sure
end
- it 'should detect ssh on standard port' do
+ it 'detects ssh on standard port' do
allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(22) # set this just to be sure
allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix))
stub_url([ config.user, '@', config.host, ':gitlab-org/gitlab-ce.git' ].join(''))
expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ])
end
- it 'should detect ssh on non-standard port' do
+ it 'detects ssh on non-standard port' do
allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(2222)
allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix))
stub_url([ 'ssh://', config.user, '@', config.host, ':2222/gitlab-org/gitlab-ce.git' ].join(''))
expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ])
end
- it 'should detect http on standard port' do
+ it 'detects http on standard port' do
allow(Gitlab.config.gitlab).to receive(:port).and_return(80)
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
stub_url([ 'http://', config.host, '/gitlab-org/gitlab-ce.git' ].join(''))
expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ])
end
- it 'should detect http on non-standard port' do
+ it 'detects http on non-standard port' do
allow(Gitlab.config.gitlab).to receive(:port).and_return(3000)
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
stub_url([ 'http://', config.host, ':3000/gitlab-org/gitlab-ce.git' ].join(''))
expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ])
end
- it 'should work with relative_url_root' do
+ it 'works with relative_url_root' do
allow(Gitlab.config.gitlab).to receive(:port).and_return(80) # set this just to be sure
allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return('/gitlab/root')
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
@@ -55,22 +55,22 @@ describe SubmoduleHelper do
end
context 'submodule on github.com' do
- it 'should detect ssh' do
+ it 'detects ssh' do
stub_url('git@github.com:gitlab-org/gitlab-ce.git')
expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
end
- it 'should detect http' do
+ it 'detects http' do
stub_url('http://github.com/gitlab-org/gitlab-ce.git')
expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
end
- it 'should detect https' do
+ it 'detects https' do
stub_url('https://github.com/gitlab-org/gitlab-ce.git')
expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
end
- it 'should return original with non-standard url' do
+ it 'returns original with non-standard url' do
stub_url('http://github.com/gitlab-org/gitlab-ce')
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
@@ -80,22 +80,22 @@ describe SubmoduleHelper do
end
context 'submodule on gitlab.com' do
- it 'should detect ssh' do
+ it 'detects ssh' do
stub_url('git@gitlab.com:gitlab-org/gitlab-ce.git')
expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
end
- it 'should detect http' do
+ it 'detects http' do
stub_url('http://gitlab.com/gitlab-org/gitlab-ce.git')
expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
end
- it 'should detect https' do
+ it 'detects https' do
stub_url('https://gitlab.com/gitlab-org/gitlab-ce.git')
expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
end
- it 'should return original with non-standard url' do
+ it 'returns original with non-standard url' do
stub_url('http://gitlab.com/gitlab-org/gitlab-ce')
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
@@ -105,7 +105,7 @@ describe SubmoduleHelper do
end
context 'submodule on unsupported' do
- it 'should return original' do
+ it 'returns original' do
stub_url('http://mygitserver.com/gitlab-org/gitlab-ce')
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
index c70dd8076e0..8d6537ba4b5 100644
--- a/spec/helpers/tree_helper_spec.rb
+++ b/spec/helpers/tree_helper_spec.rb
@@ -12,7 +12,7 @@ describe TreeHelper do
context "on a directory containing more than one file/directory" do
let(:tree_item) { double(name: "files", path: "files") }
- it "should return the directory name" do
+ it "returns the directory name" do
expect(flatten_tree(tree_item)).to match('files')
end
end
@@ -20,7 +20,7 @@ describe TreeHelper do
context "on a directory containing only one directory" do
let(:tree_item) { double(name: "foo", path: "foo") }
- it "should return the flattened path" do
+ it "returns the flattened path" do
expect(flatten_tree(tree_item)).to match('foo/bar')
end
end
diff --git a/spec/javascripts/datetime_utility_spec.js.coffee b/spec/javascripts/datetime_utility_spec.js.coffee
new file mode 100644
index 00000000000..6b9617341fe
--- /dev/null
+++ b/spec/javascripts/datetime_utility_spec.js.coffee
@@ -0,0 +1,31 @@
+#= require lib/utils/datetime_utility
+
+describe 'Date time utils', ->
+ describe 'get day name', ->
+ it 'should return Sunday', ->
+ day = gl.utils.getDayName(new Date('07/17/2016'))
+ expect(day).toBe('Sunday')
+
+ it 'should return Monday', ->
+ day = gl.utils.getDayName(new Date('07/18/2016'))
+ expect(day).toBe('Monday')
+
+ it 'should return Tuesday', ->
+ day = gl.utils.getDayName(new Date('07/19/2016'))
+ expect(day).toBe('Tuesday')
+
+ it 'should return Wednesday', ->
+ day = gl.utils.getDayName(new Date('07/20/2016'))
+ expect(day).toBe('Wednesday')
+
+ it 'should return Thursday', ->
+ day = gl.utils.getDayName(new Date('07/21/2016'))
+ expect(day).toBe('Thursday')
+
+ it 'should return Friday', ->
+ day = gl.utils.getDayName(new Date('07/22/2016'))
+ expect(day).toBe('Friday')
+
+ it 'should return Saturday', ->
+ day = gl.utils.getDayName(new Date('07/23/2016'))
+ expect(day).toBe('Saturday')
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb
index 224baca8030..bda8d2ce38a 100644
--- a/spec/lib/banzai/filter/relative_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb
@@ -84,6 +84,11 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do
to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
+ it 'ignores absolute URLs with two leading slashes' do
+ doc = filter(link('//doc/api/README.md'))
+ expect(doc.at_css('a')['href']).to eq '//doc/api/README.md'
+ end
+
it 'rebuilds relative URL for a file in the repo' do
doc = filter(link('doc/api/README.md'))
expect(doc.at_css('a')['href']).
diff --git a/spec/lib/banzai/filter/video_link_filter_spec.rb b/spec/lib/banzai/filter/video_link_filter_spec.rb
index cc4349f80ba..6ab1be9ccb7 100644
--- a/spec/lib/banzai/filter/video_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/video_link_filter_spec.rb
@@ -47,5 +47,4 @@ describe Banzai::Filter::VideoLinkFilter, lib: true do
expect(element['src']).to eq '/path/my_image.jpg'
end
end
-
end
diff --git a/spec/lib/ci/charts_spec.rb b/spec/lib/ci/charts_spec.rb
index 97f2e97b062..034ea098193 100644
--- a/spec/lib/ci/charts_spec.rb
+++ b/spec/lib/ci/charts_spec.rb
@@ -7,12 +7,12 @@ describe Ci::Charts, lib: true do
FactoryGirl.create(:ci_build, pipeline: @pipeline)
end
- it 'should return build times in minutes' do
+ it 'returns build times in minutes' do
chart = Ci::Charts::BuildTime.new(@pipeline.project)
expect(chart.build_times).to eq([2])
end
- it 'should handle nil build times' do
+ it 'handles nil build times' do
create(:ci_pipeline, duration: nil, project: @pipeline.project)
chart = Ci::Charts::BuildTime.new(@pipeline.project)
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
index 61490555ff5..be51d942af7 100644
--- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
@@ -19,7 +19,7 @@ module Ci
expect(config_processor.builds_for_stage_and_ref(type, "master").first).to eq({
stage: "test",
stage_idx: 1,
- name: :rspec,
+ name: "rspec",
commands: "pwd\nrspec",
tag_list: [],
options: {},
@@ -433,7 +433,7 @@ module Ci
expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
stage: "test",
stage_idx: 1,
- name: :rspec,
+ name: "rspec",
commands: "pwd\nrspec",
tag_list: [],
options: {
@@ -461,7 +461,7 @@ module Ci
expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
stage: "test",
stage_idx: 1,
- name: :rspec,
+ name: "rspec",
commands: "pwd\nrspec",
tag_list: [],
options: {
@@ -533,10 +533,6 @@ module Ci
}
end
- context 'when also global variables are defined' do
-
- end
-
context 'when syntax is correct' do
let(:variables) do
{ VAR1: 'value1', VAR2: 'value2' }
@@ -704,7 +700,7 @@ module Ci
expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
stage: "test",
stage_idx: 1,
- name: :rspec,
+ name: "rspec",
commands: "pwd\nrspec",
tag_list: [],
options: {
@@ -841,7 +837,7 @@ module Ci
expect(subject.first).to eq({
stage: "test",
stage_idx: 1,
- name: :normal_job,
+ name: "normal_job",
commands: "test",
tag_list: [],
options: {},
@@ -886,7 +882,7 @@ module Ci
expect(subject.first).to eq({
stage: "build",
stage_idx: 0,
- name: :job1,
+ name: "job1",
commands: "execute-script-for-job",
tag_list: [],
options: {},
@@ -898,7 +894,7 @@ module Ci
expect(subject.second).to eq({
stage: "build",
stage_idx: 0,
- name: :job2,
+ name: "job2",
commands: "execute-script-for-job",
tag_list: [],
options: {},
diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb
index 309a88151cf..8f51474476d 100644
--- a/spec/lib/disable_email_interceptor_spec.rb
+++ b/spec/lib/disable_email_interceptor_spec.rb
@@ -5,7 +5,7 @@ describe DisableEmailInterceptor, lib: true do
Mail.register_interceptor(DisableEmailInterceptor)
end
- it 'should not send emails' do
+ it 'does not send emails' do
allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false)
expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count)
end
diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb
index 566035c60d0..b12a7b98d4d 100644
--- a/spec/lib/extracts_path_spec.rb
+++ b/spec/lib/extracts_path_spec.rb
@@ -25,7 +25,7 @@ describe ExtractsPath, lib: true do
@project = create(:project)
end
- it "log tree path should have no escape sequences" do
+ it "log tree path has no escape sequences" do
assign_ref_vars
expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb")
end
@@ -33,7 +33,7 @@ describe ExtractsPath, lib: true do
context 'escaped sequences in ref' do
let(:ref) { "improve%2Fawesome" }
- it "id should have no escape sequences" do
+ it "id has no escape sequences" do
assign_ref_vars
expect(@ref).to eq('improve/awesome')
expect(@logs_path).to eq("/#{@project.path_with_namespace}/refs/#{ref}/logs_tree/files/ruby/popen.rb")
diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb
index 32ca8239845..4aba783dc33 100644
--- a/spec/lib/gitlab/asciidoc_spec.rb
+++ b/spec/lib/gitlab/asciidoc_spec.rb
@@ -8,7 +8,7 @@ module Gitlab
let(:html) { 'H<sub>2</sub>O' }
context "without project" do
- it "should convert the input using Asciidoctor and default options" do
+ it "converts the input using Asciidoctor and default options" do
expected_asciidoc_opts = {
safe: :secure,
backend: :html5,
@@ -24,7 +24,7 @@ module Gitlab
context "with asciidoc_opts" do
let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } }
- it "should merge the options with default ones" do
+ it "merges the options with default ones" do
expected_asciidoc_opts = {
safe: :safe,
backend: :html5,
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb
index 7bec1367156..b0772cad312 100644
--- a/spec/lib/gitlab/auth_spec.rb
+++ b/spec/lib/gitlab/auth_spec.rb
@@ -51,24 +51,24 @@ describe Gitlab::Auth, lib: true do
let(:username) { 'John' } # username isn't lowercase, test this
let(:password) { 'my-secret' }
- it "should find user by valid login/password" do
+ it "finds user by valid login/password" do
expect( gl_auth.find_with_user_password(username, password) ).to eql user
end
- it 'should find user by valid email/password with case-insensitive email' do
+ it 'finds user by valid email/password with case-insensitive email' do
expect(gl_auth.find_with_user_password(user.email.upcase, password)).to eql user
end
- it 'should find user by valid username/password with case-insensitive username' do
+ it 'finds user by valid username/password with case-insensitive username' do
expect(gl_auth.find_with_user_password(username.upcase, password)).to eql user
end
- it "should not find user with invalid password" do
+ it "does not find user with invalid password" do
password = 'wrong'
expect( gl_auth.find_with_user_password(username, password) ).not_to eql user
end
- it "should not find user with invalid login" do
+ it "does not find user with invalid login" do
user = 'wrong'
expect( gl_auth.find_with_user_password(username, password) ).not_to eql user
end
diff --git a/spec/lib/gitlab/ci/config/node/validatable_spec.rb b/spec/lib/gitlab/ci/config/node/validatable_spec.rb
index 10cd01afcd1..64b77fd6e03 100644
--- a/spec/lib/gitlab/ci/config/node/validatable_spec.rb
+++ b/spec/lib/gitlab/ci/config/node/validatable_spec.rb
@@ -23,6 +23,10 @@ describe Gitlab::Ci::Config::Node::Validatable do
.to be Gitlab::Ci::Config::Node::Validator
end
+ it 'returns only one validator to mitigate leaks' do
+ expect { node.validator }.not_to change { node.validator }
+ end
+
context 'when validating node instance' do
let(:node_instance) { node.new }
diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb
index e9b8ce6b5bb..de3f64249a2 100644
--- a/spec/lib/gitlab/closing_issue_extractor_spec.rb
+++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb
@@ -3,10 +3,12 @@ require 'spec_helper'
describe Gitlab::ClosingIssueExtractor, lib: true do
let(:project) { create(:project) }
let(:project2) { create(:project) }
+ let(:forked_project) { Projects::ForkService.new(project, project.creator).execute }
let(:issue) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project2) }
let(:reference) { issue.to_reference }
let(:cross_reference) { issue2.to_reference(project) }
+ let(:fork_cross_reference) { issue.to_reference(forked_project) }
subject { described_class.new(project, project.creator) }
@@ -278,6 +280,15 @@ describe Gitlab::ClosingIssueExtractor, lib: true do
end
end
+ context "with a cross-project fork reference" do
+ subject { described_class.new(forked_project, forked_project.creator) }
+
+ it do
+ message = "Closes #{fork_cross_reference}"
+ expect(subject.closed_by_message(message)).to be_empty
+ end
+ end
+
context "with an invalid URL" do
it do
message = "Closes https://google.com#{urls.namespace_project_issue_path(issue2.project.namespace, issue2.project, issue2)}"
diff --git a/spec/lib/gitlab/git/hook_spec.rb b/spec/lib/gitlab/git/hook_spec.rb
index a15aa173fbd..d1f947b6850 100644
--- a/spec/lib/gitlab/git/hook_spec.rb
+++ b/spec/lib/gitlab/git/hook_spec.rb
@@ -25,7 +25,6 @@ describe Gitlab::Git::Hook, lib: true do
end
['pre-receive', 'post-receive', 'update'].each do |hook_name|
-
context "when triggering a #{hook_name} hook" do
context "when the hook is successful" do
it "returns success with no errors" do
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index 8447305a316..f12c9a370f7 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -19,11 +19,11 @@ describe Gitlab::GitAccess, lib: true do
end
it 'blocks ssh git push' do
- expect(@acc.check('git-receive-pack').allowed?).to be_falsey
+ expect(@acc.check('git-receive-pack', '_any').allowed?).to be_falsey
end
it 'blocks ssh git pull' do
- expect(@acc.check('git-upload-pack').allowed?).to be_falsey
+ expect(@acc.check('git-upload-pack', '_any').allowed?).to be_falsey
end
end
@@ -34,17 +34,17 @@ describe Gitlab::GitAccess, lib: true do
end
it 'blocks http push' do
- expect(@acc.check('git-receive-pack').allowed?).to be_falsey
+ expect(@acc.check('git-receive-pack', '_any').allowed?).to be_falsey
end
it 'blocks http git pull' do
- expect(@acc.check('git-upload-pack').allowed?).to be_falsey
+ expect(@acc.check('git-upload-pack', '_any').allowed?).to be_falsey
end
end
end
describe 'download_access_check' do
- subject { access.check('git-upload-pack') }
+ subject { access.check('git-upload-pack', '_any') }
describe 'master permissions' do
before { project.team << [user, :master] }
@@ -288,7 +288,7 @@ describe Gitlab::GitAccess, lib: true do
let(:actor) { key }
context 'push code' do
- subject { access.check('git-receive-pack') }
+ subject { access.check('git-receive-pack', '_any') }
context 'when project is authorized' do
before { key.projects << project }
diff --git a/spec/lib/gitlab/import_export/members_mapper_spec.rb b/spec/lib/gitlab/import_export/members_mapper_spec.rb
index 6d5aa0d04a2..770e8b0c2f4 100644
--- a/spec/lib/gitlab/import_export/members_mapper_spec.rb
+++ b/spec/lib/gitlab/import_export/members_mapper_spec.rb
@@ -26,6 +26,20 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
"email" => user2.email,
"username" => user2.username
}
+ },
+ {
+ "id" => 3,
+ "access_level" => 40,
+ "source_id" => 14,
+ "source_type" => "Project",
+ "user_id" => nil,
+ "notification_level" => 3,
+ "created_at" => "2016-03-11T10:21:44.822Z",
+ "updated_at" => "2016-03-11T10:21:44.822Z",
+ "created_by_id" => 1,
+ "invite_email" => 'invite@test.com',
+ "invite_token" => 'token',
+ "invite_accepted_at" => nil
}]
end
@@ -47,5 +61,11 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
expect(members_mapper.missing_author_ids.first).to eq(-1)
end
+
+ it 'has invited members with no user' do
+ members_mapper.map
+
+ expect(ProjectMember.find_by_invite_email('invite@test.com')).not_to be_nil
+ end
end
end
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index 32c0d6462f1..5fdd4d5f25f 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -2,7 +2,6 @@ require 'spec_helper'
describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
describe 'restore project tree' do
-
let(:user) { create(:user) }
let(:namespace) { create(:namespace, owner: user) }
let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: "", project_path: 'path') }
diff --git a/spec/lib/gitlab/ldap/access_spec.rb b/spec/lib/gitlab/ldap/access_spec.rb
index acd5394382c..534bcbf39fe 100644
--- a/spec/lib/gitlab/ldap/access_spec.rb
+++ b/spec/lib/gitlab/ldap/access_spec.rb
@@ -64,7 +64,7 @@ describe Gitlab::LDAP::Access, lib: true do
user.ldap_block
end
- it 'should unblock user in GitLab' do
+ it 'unblocks user in GitLab' do
access.allowed?
expect(user).not_to be_blocked
end
diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb
index 949f6e2b19a..89790c9e1af 100644
--- a/spec/lib/gitlab/ldap/user_spec.rb
+++ b/spec/lib/gitlab/ldap/user_spec.rb
@@ -36,7 +36,7 @@ describe Gitlab::LDAP::User, lib: true do
expect(ldap_user.changed?).to be_truthy
end
- it "dont marks existing ldap user as changed" do
+ it "does not mark existing ldap user as changed" do
create(:omniauth_user, email: 'john@example.com', extern_uid: 'my-uid', provider: 'ldapmain', ldap_email: true)
expect(ldap_user.changed?).to be_falsey
end
diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb
index 1fca8a13037..78c669e8fa5 100644
--- a/spec/lib/gitlab/o_auth/user_spec.rb
+++ b/spec/lib/gitlab/o_auth/user_spec.rb
@@ -42,7 +42,7 @@ describe Gitlab::OAuth::User, lib: true do
describe 'signup' do
shared_examples 'to verify compliance with allow_single_sign_on' do
context 'provider is marked as external' do
- it 'should mark user as external' do
+ it 'marks user as external' do
stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['twitter'])
oauth_user.save
expect(gl_user).to be_valid
@@ -51,7 +51,7 @@ describe Gitlab::OAuth::User, lib: true do
end
context 'provider was external, now has been removed' do
- it 'should not mark external user as internal' do
+ it 'does not mark external user as internal' do
create(:omniauth_user, extern_uid: 'my-uid', provider: 'twitter', external: true)
stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['facebook'])
oauth_user.save
@@ -62,7 +62,7 @@ describe Gitlab::OAuth::User, lib: true do
context 'provider is not external' do
context 'when adding a new OAuth identity' do
- it 'should not promote an external user to internal' do
+ it 'does not promote an external user to internal' do
user = create(:user, email: 'john@mail.com', external: true)
user.identities.create(provider: provider, extern_uid: uid)
diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb
index 270b89972d7..29abb4d4d07 100644
--- a/spec/lib/gitlab/project_search_results_spec.rb
+++ b/spec/lib/gitlab/project_search_results_spec.rb
@@ -33,7 +33,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
let!(:security_issue_1) { create(:issue, :confidential, project: project, title: 'Security issue 1', author: author) }
let!(:security_issue_2) { create(:issue, :confidential, title: 'Security issue 2', project: project, assignee: assignee) }
- it 'should not list project confidential issues for non project members' do
+ it 'does not list project confidential issues for non project members' do
results = described_class.new(non_member, project, query)
issues = results.objects('issues')
@@ -43,7 +43,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
expect(results.issues_count).to eq 1
end
- it 'should not list project confidential issues for project members with guest role' do
+ it 'does not list project confidential issues for project members with guest role' do
project.team << [member, :guest]
results = described_class.new(member, project, query)
@@ -55,7 +55,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
expect(results.issues_count).to eq 1
end
- it 'should list project confidential issues for author' do
+ it 'lists project confidential issues for author' do
results = described_class.new(author, project, query)
issues = results.objects('issues')
@@ -65,7 +65,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
expect(results.issues_count).to eq 2
end
- it 'should list project confidential issues for assignee' do
+ it 'lists project confidential issues for assignee' do
results = described_class.new(assignee, project.id, query)
issues = results.objects('issues')
@@ -75,7 +75,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
expect(results.issues_count).to eq 2
end
- it 'should list project confidential issues for project members' do
+ it 'lists project confidential issues for project members' do
project.team << [member, :developer]
results = described_class.new(member, project, query)
@@ -87,7 +87,7 @@ describe Gitlab::ProjectSearchResults, lib: true do
expect(results.issues_count).to eq 3
end
- it 'should list all project issues for admin' do
+ it 'lists all project issues for admin' do
results = described_class.new(admin, project, query)
issues = results.objects('issues')
diff --git a/spec/lib/gitlab/saml/user_spec.rb b/spec/lib/gitlab/saml/user_spec.rb
index 56bf08e7041..02c139f1a0d 100644
--- a/spec/lib/gitlab/saml/user_spec.rb
+++ b/spec/lib/gitlab/saml/user_spec.rb
@@ -67,7 +67,7 @@ describe Gitlab::Saml::User, lib: true do
end
context 'user was external, now should not be' do
- it 'should make user internal' do
+ it 'makes user internal' do
existing_user.update_attribute('external', true)
saml_user.save
expect(gl_user).to be_valid
@@ -94,14 +94,14 @@ describe Gitlab::Saml::User, lib: true do
context 'with allow_single_sign_on default (["saml"])' do
before { stub_omniauth_config(allow_single_sign_on: ['saml']) }
- it 'should not throw an error' do
+ it 'does not throw an error' do
expect{ saml_user.save }.not_to raise_error
end
end
context 'with allow_single_sign_on disabled' do
before { stub_omniauth_config(allow_single_sign_on: false) }
- it 'should throw an error' do
+ it 'throws an error' do
expect{ saml_user.save }.to raise_error StandardError
end
end
@@ -223,7 +223,7 @@ describe Gitlab::Saml::User, lib: true do
context 'dont block on create' do
before { stub_omniauth_config(block_auto_created_users: false) }
- it 'should not block the user' do
+ it 'does not block the user' do
saml_user.save
expect(gl_user).to be_valid
expect(gl_user).not_to be_blocked
@@ -233,7 +233,7 @@ describe Gitlab::Saml::User, lib: true do
context 'block on create' do
before { stub_omniauth_config(block_auto_created_users: true) }
- it 'should block user' do
+ it 'blocks user' do
saml_user.save
expect(gl_user).to be_valid
expect(gl_user).to be_blocked
diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb
index 1bb444bf34f..8a656ab0ee9 100644
--- a/spec/lib/gitlab/search_results_spec.rb
+++ b/spec/lib/gitlab/search_results_spec.rb
@@ -73,7 +73,7 @@ describe Gitlab::SearchResults do
let!(:security_issue_4) { create(:issue, :confidential, project: project_3, title: 'Security issue 4', assignee: assignee) }
let!(:security_issue_5) { create(:issue, :confidential, project: project_4, title: 'Security issue 5') }
- it 'should not list confidential issues for non project members' do
+ it 'does not list confidential issues for non project members' do
results = described_class.new(non_member, limit_projects, query)
issues = results.objects('issues')
@@ -86,7 +86,7 @@ describe Gitlab::SearchResults do
expect(results.issues_count).to eq 1
end
- it 'should not list confidential issues for project members with guest role' do
+ it 'does not list confidential issues for project members with guest role' do
project_1.team << [member, :guest]
project_2.team << [member, :guest]
@@ -102,7 +102,7 @@ describe Gitlab::SearchResults do
expect(results.issues_count).to eq 1
end
- it 'should list confidential issues for author' do
+ it 'lists confidential issues for author' do
results = described_class.new(author, limit_projects, query)
issues = results.objects('issues')
@@ -115,7 +115,7 @@ describe Gitlab::SearchResults do
expect(results.issues_count).to eq 3
end
- it 'should list confidential issues for assignee' do
+ it 'lists confidential issues for assignee' do
results = described_class.new(assignee, limit_projects, query)
issues = results.objects('issues')
@@ -128,7 +128,7 @@ describe Gitlab::SearchResults do
expect(results.issues_count).to eq 3
end
- it 'should list confidential issues for project members' do
+ it 'lists confidential issues for project members' do
project_1.team << [member, :developer]
project_2.team << [member, :developer]
@@ -144,7 +144,7 @@ describe Gitlab::SearchResults do
expect(results.issues_count).to eq 4
end
- it 'should list all issues for admin' do
+ it 'lists all issues for admin' do
results = described_class.new(admin, limit_projects, query)
issues = results.objects('issues')
diff --git a/spec/lib/gitlab/upgrader_spec.rb b/spec/lib/gitlab/upgrader_spec.rb
index e958e087a80..edadab043d7 100644
--- a/spec/lib/gitlab/upgrader_spec.rb
+++ b/spec/lib/gitlab/upgrader_spec.rb
@@ -9,19 +9,19 @@ describe Gitlab::Upgrader, lib: true do
end
describe 'latest_version?' do
- it 'should be true if newest version' do
+ it 'is true if newest version' do
allow(upgrader).to receive(:latest_version_raw).and_return(current_version)
expect(upgrader.latest_version?).to be_truthy
end
end
describe 'latest_version_raw' do
- it 'should be latest version for GitLab 5' do
+ it 'is the latest version for GitLab 5' do
allow(upgrader).to receive(:current_version_raw).and_return("5.3.0")
expect(upgrader.latest_version_raw).to eq("v5.4.2")
end
- it 'should get the latest version from tags' do
+ it 'gets the latest version from tags' do
allow(upgrader).to receive(:fetch_git_tags).and_return([
'6f0733310546402c15d3ae6128a95052f6c8ea96 refs/tags/v7.1.1',
'facfec4b242ce151af224e20715d58e628aa5e74 refs/tags/v7.1.1^{}',
diff --git a/spec/lib/gitlab/user_access_spec.rb b/spec/lib/gitlab/user_access_spec.rb
index 5bb095366fa..d3c3b800b94 100644
--- a/spec/lib/gitlab/user_access_spec.rb
+++ b/spec/lib/gitlab/user_access_spec.rb
@@ -9,35 +9,80 @@ describe Gitlab::UserAccess, lib: true do
describe 'push to none protected branch' do
it 'returns true if user is a master' do
project.team << [user, :master]
+
expect(access.can_push_to_branch?('random_branch')).to be_truthy
end
it 'returns true if user is a developer' do
project.team << [user, :developer]
+
expect(access.can_push_to_branch?('random_branch')).to be_truthy
end
it 'returns false if user is a reporter' do
project.team << [user, :reporter]
+
expect(access.can_push_to_branch?('random_branch')).to be_falsey
end
end
+ describe 'push to empty project' do
+ let(:empty_project) { create(:project_empty_repo) }
+ let(:project_access) { Gitlab::UserAccess.new(user, project: empty_project) }
+
+ it 'returns true if user is master' do
+ empty_project.team << [user, :master]
+
+ expect(project_access.can_push_to_branch?('master')).to be_truthy
+ end
+
+ it 'returns false if user is developer and project is fully protected' do
+ empty_project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_FULL)
+
+ expect(project_access.can_push_to_branch?('master')).to be_falsey
+ end
+
+ it 'returns false if user is developer and it is not allowed to push new commits but can merge into branch' do
+ empty_project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
+
+ expect(project_access.can_push_to_branch?('master')).to be_falsey
+ end
+
+ it 'returns true if user is developer and project is unprotected' do
+ empty_project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
+
+ expect(project_access.can_push_to_branch?('master')).to be_truthy
+ end
+
+ it 'returns true if user is developer and project grants developers permission' do
+ empty_project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
+
+ expect(project_access.can_push_to_branch?('master')).to be_truthy
+ end
+ end
+
describe 'push to protected branch' do
let(:branch) { create :protected_branch, project: project }
it 'returns true if user is a master' do
project.team << [user, :master]
+
expect(access.can_push_to_branch?(branch.name)).to be_truthy
end
it 'returns false if user is a developer' do
project.team << [user, :developer]
+
expect(access.can_push_to_branch?(branch.name)).to be_falsey
end
it 'returns false if user is a reporter' do
project.team << [user, :reporter]
+
expect(access.can_push_to_branch?(branch.name)).to be_falsey
end
end
@@ -49,16 +94,19 @@ describe Gitlab::UserAccess, lib: true do
it 'returns true if user is a master' do
project.team << [user, :master]
+
expect(access.can_push_to_branch?(@branch.name)).to be_truthy
end
it 'returns true if user is a developer' do
project.team << [user, :developer]
+
expect(access.can_push_to_branch?(@branch.name)).to be_truthy
end
it 'returns false if user is a reporter' do
project.team << [user, :reporter]
+
expect(access.can_push_to_branch?(@branch.name)).to be_falsey
end
end
@@ -70,19 +118,21 @@ describe Gitlab::UserAccess, lib: true do
it 'returns true if user is a master' do
project.team << [user, :master]
+
expect(access.can_merge_to_branch?(@branch.name)).to be_truthy
end
it 'returns true if user is a developer' do
project.team << [user, :developer]
+
expect(access.can_merge_to_branch?(@branch.name)).to be_truthy
end
it 'returns false if user is a reporter' do
project.team << [user, :reporter]
+
expect(access.can_merge_to_branch?(@branch.name)).to be_falsey
end
end
-
end
end
diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb
index c6758ccad39..781472d0c00 100644
--- a/spec/mailers/emails/profile_spec.rb
+++ b/spec/mailers/emails/profile_spec.rb
@@ -48,7 +48,7 @@ describe Notify do
it_behaves_like 'it should not have Gmail Actions links'
it_behaves_like 'a user cannot unsubscribe through footer link'
- it 'should not contain the new user\'s password' do
+ it 'does not contain the new user\'s password' do
is_expected.not_to have_body_text /password/
end
end
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index e2866ef160c..fa241867858 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -591,7 +591,7 @@ describe Notify do
is_expected.to have_body_text /#{note.note}/
end
- it 'not contains note author' do
+ it 'does not contain note author' do
is_expected.not_to have_body_text /wrote\:/
end
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index fb040ba82bc..cc215d252f9 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -53,59 +53,59 @@ describe ApplicationSetting, models: true do
end
context 'restricted signup domains' do
- it 'set single domain' do
+ it 'sets single domain' do
setting.domain_whitelist_raw = 'example.com'
expect(setting.domain_whitelist).to eq(['example.com'])
end
- it 'set multiple domains with spaces' do
+ it 'sets multiple domains with spaces' do
setting.domain_whitelist_raw = 'example.com *.example.com'
expect(setting.domain_whitelist).to eq(['example.com', '*.example.com'])
end
- it 'set multiple domains with newlines and a space' do
+ it 'sets multiple domains with newlines and a space' do
setting.domain_whitelist_raw = "example.com\n *.example.com"
expect(setting.domain_whitelist).to eq(['example.com', '*.example.com'])
end
- it 'set multiple domains with commas' do
+ it 'sets multiple domains with commas' do
setting.domain_whitelist_raw = "example.com, *.example.com"
expect(setting.domain_whitelist).to eq(['example.com', '*.example.com'])
end
end
context 'blacklisted signup domains' do
- it 'set single domain' do
+ it 'sets single domain' do
setting.domain_blacklist_raw = 'example.com'
expect(setting.domain_blacklist).to contain_exactly('example.com')
end
- it 'set multiple domains with spaces' do
+ it 'sets multiple domains with spaces' do
setting.domain_blacklist_raw = 'example.com *.example.com'
expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com')
end
- it 'set multiple domains with newlines and a space' do
+ it 'sets multiple domains with newlines and a space' do
setting.domain_blacklist_raw = "example.com\n *.example.com"
expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com')
end
- it 'set multiple domains with commas' do
+ it 'sets multiple domains with commas' do
setting.domain_blacklist_raw = "example.com, *.example.com"
expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com')
end
- it 'set multiple domains with semicolon' do
+ it 'sets multiple domains with semicolon' do
setting.domain_blacklist_raw = "example.com; *.example.com"
expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com')
end
- it 'set multiple domains with mixture of everything' do
+ it 'sets multiple domains with mixture of everything' do
setting.domain_blacklist_raw = "example.com; *.example.com\n test.com\sblock.com yes.com"
expect(setting.domain_blacklist).to contain_exactly('example.com', '*.example.com', 'test.com', 'block.com', 'yes.com')
end
- it 'set multiple domain with file' do
+ it 'sets multiple domain with file' do
setting.domain_blacklist_file = File.open(Rails.root.join('spec/fixtures/', 'domain_blacklist.txt'))
expect(setting.domain_blacklist).to contain_exactly('example.com', 'test.com', 'foo.bar')
end
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 6ad8bfef4f2..72688137f08 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -23,19 +23,19 @@ describe BroadcastMessage, models: true do
end
describe '.current' do
- it "should return last message if time match" do
+ it "returns last message if time match" do
message = create(:broadcast_message)
expect(BroadcastMessage.current).to eq message
end
- it "should return nil if time not come" do
+ it "returns nil if time not come" do
create(:broadcast_message, :future)
expect(BroadcastMessage.current).to be_nil
end
- it "should return nil if time has passed" do
+ it "returns nil if time has passed" do
create(:broadcast_message, :expired)
expect(BroadcastMessage.current).to be_nil
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index b4ddd7ea2fa..395316a8766 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -32,7 +32,7 @@ describe Ci::Build, models: true do
end
let(:create_from_build) { Ci::Build.create_from build }
- it 'there should be a pending task' do
+ it 'exists a pending task' do
expect(Ci::Build.pending.count(:all)).to eq 0
create_from_build
expect(Ci::Build.pending.count(:all)).to be > 0
@@ -574,19 +574,19 @@ describe Ci::Build, models: true do
let!(:rubocop_test) { create(:ci_build, pipeline: pipeline, name: 'rubocop', stage_idx: 1, stage: 'test') }
let!(:staging) { create(:ci_build, pipeline: pipeline, name: 'staging', stage_idx: 2, stage: 'deploy') }
- it 'to have no dependents if this is first build' do
+ it 'expects to have no dependents if this is first build' do
expect(build.depends_on_builds).to be_empty
end
- it 'to have one dependent if this is test' do
+ it 'expects to have one dependent if this is test' do
expect(rspec_test.depends_on_builds.map(&:id)).to contain_exactly(build.id)
end
- it 'to have all builds from build and test stage if this is last' do
+ it 'expects to have all builds from build and test stage if this is last' do
expect(staging.depends_on_builds.map(&:id)).to contain_exactly(build.id, rspec_test.id, rubocop_test.id)
end
- it 'to have retried builds instead the original ones' do
+ it 'expects to have retried builds instead the original ones' do
retried_rspec = Ci::Build.retry(rspec_test)
expect(staging.depends_on_builds.map(&:id)).to contain_exactly(build.id, retried_rspec.id, rubocop_test.id)
end
@@ -656,23 +656,23 @@ describe Ci::Build, models: true do
describe 'build erasable' do
shared_examples 'erasable' do
- it 'should remove artifact file' do
+ it 'removes artifact file' do
expect(build.artifacts_file.exists?).to be_falsy
end
- it 'should remove artifact metadata file' do
+ it 'removes artifact metadata file' do
expect(build.artifacts_metadata.exists?).to be_falsy
end
- it 'should erase build trace in trace file' do
+ it 'erases build trace in trace file' do
expect(build.trace).to be_empty
end
- it 'should set erased to true' do
+ it 'sets erased to true' do
expect(build.erased?).to be true
end
- it 'should set erase date' do
+ it 'sets erase date' do
expect(build.erased_at).not_to be_falsy
end
end
@@ -705,7 +705,7 @@ describe Ci::Build, models: true do
include_examples 'erasable'
- it 'should record user who erased a build' do
+ it 'records user who erased a build' do
expect(build.erased_by).to eq user
end
end
@@ -715,7 +715,7 @@ describe Ci::Build, models: true do
include_examples 'erasable'
- it 'should not set user who erased a build' do
+ it 'does not set user who erased a build' do
expect(build.erased_by).to be_nil
end
end
@@ -751,7 +751,7 @@ describe Ci::Build, models: true do
end
describe '#erase' do
- it 'should not raise error' do
+ it 'does not raise error' do
expect { build.erase }.not_to raise_error
end
end
@@ -949,7 +949,7 @@ describe Ci::Build, models: true do
context 'when build is running' do
before { build.run! }
- it 'should return false' do
+ it 'returns false' do
expect(build.retryable?).to be false
end
end
@@ -957,7 +957,7 @@ describe Ci::Build, models: true do
context 'when build is finished' do
before { build.success! }
- it 'should return true' do
+ it 'returns true' do
expect(build.retryable?).to be true
end
end
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index d676e32646a..79141a9d94e 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -139,13 +139,13 @@ describe Ci::Pipeline, models: true do
end
end
- describe '#update_state' do
+ describe '#reload_status!' do
let(:pipeline) { create :ci_empty_pipeline, project: project }
context 'dependent objects' do
let(:commit_status) { create :commit_status, pipeline: pipeline }
- it 'execute reload_status! after commit status succeeds' do
+ it 'executes reload_status! after succeeding dependent object' do
expect(pipeline).to receive(:reload_status!).and_return(true)
commit_status.success
end
diff --git a/spec/models/ci/trigger_spec.rb b/spec/models/ci/trigger_spec.rb
index 474b0b1621d..3ca9231f58e 100644
--- a/spec/models/ci/trigger_spec.rb
+++ b/spec/models/ci/trigger_spec.rb
@@ -4,12 +4,12 @@ describe Ci::Trigger, models: true do
let(:project) { FactoryGirl.create :empty_project }
describe 'before_validation' do
- it 'should set an random token if none provided' do
+ it 'sets an random token if none provided' do
trigger = FactoryGirl.create :ci_trigger_without_token, project: project
expect(trigger.token).not_to be_nil
end
- it 'should not set an random token if one provided' do
+ it 'does not set an random token if one provided' do
trigger = FactoryGirl.create :ci_trigger, project: project
expect(trigger.token).to eq('token')
end
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index ff6371ad685..fcfa3138ce5 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -133,7 +133,7 @@ describe CommitStatus, models: true do
@commit5 = FactoryGirl.create :commit_status, pipeline: pipeline, name: 'aa', ref: 'bb', status: 'success'
end
- it 'return unique statuses' do
+ it 'returns unique statuses' do
is_expected.to eq([@commit4, @commit5])
end
end
@@ -149,7 +149,7 @@ describe CommitStatus, models: true do
@commit5 = FactoryGirl.create :commit_status, pipeline: pipeline, name: 'ee', ref: nil, status: 'canceled'
end
- it 'return statuses that are running or pending' do
+ it 'returns statuses that are running or pending' do
is_expected.to eq([@commit1, @commit2])
end
end
@@ -160,7 +160,7 @@ describe CommitStatus, models: true do
context 'when no before_sha is set for pipeline' do
before { pipeline.before_sha = nil }
- it 'return blank sha' do
+ it 'returns blank sha' do
is_expected.to eq(Gitlab::Git::BLANK_SHA)
end
end
@@ -169,7 +169,7 @@ describe CommitStatus, models: true do
let(:value) { '1234' }
before { pipeline.before_sha = value }
- it 'return the set value' do
+ it 'returns the set value' do
is_expected.to eq(value)
end
end
@@ -186,7 +186,7 @@ describe CommitStatus, models: true do
context 'stages list' do
subject { CommitStatus.where(pipeline: pipeline).stages }
- it 'return ordered list of stages' do
+ it 'returns ordered list of stages' do
is_expected.to eq(%w(build test deploy))
end
end
@@ -194,7 +194,7 @@ describe CommitStatus, models: true do
context 'stages with statuses' do
subject { CommitStatus.where(pipeline: pipeline).latest.stages_status }
- it 'return list of stages with statuses' do
+ it 'returns list of stages with statuses' do
is_expected.to eq({
'build' => 'failed',
'test' => 'success',
diff --git a/spec/models/concerns/faster_cache_keys_spec.rb b/spec/models/concerns/faster_cache_keys_spec.rb
new file mode 100644
index 00000000000..8d3f94267fa
--- /dev/null
+++ b/spec/models/concerns/faster_cache_keys_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe FasterCacheKeys do
+ describe '#cache_key' do
+ it 'returns a String' do
+ # We're using a fixed string here so it's easier to set an expectation for
+ # the resulting cache key.
+ time = '2016-08-08 16:39:00+02'
+ issue = build(:issue, updated_at: time)
+ issue.extend(described_class)
+
+ expect(issue).to receive(:id).and_return(1)
+
+ expect(issue.cache_key).to eq("issues/1-#{time}")
+ end
+ end
+end
diff --git a/spec/models/concerns/milestoneish_spec.rb b/spec/models/concerns/milestoneish_spec.rb
index 7e9ab8940cf..b7e973798a3 100644
--- a/spec/models/concerns/milestoneish_spec.rb
+++ b/spec/models/concerns/milestoneish_spec.rb
@@ -26,53 +26,53 @@ describe Milestone, 'Milestoneish' do
end
describe '#closed_items_count' do
- it 'should not count confidential issues for non project members' do
+ it 'does not count confidential issues for non project members' do
expect(milestone.closed_items_count(non_member)).to eq 2
end
- it 'should not count confidential issues for project members with guest role' do
+ it 'does not count confidential issues for project members with guest role' do
expect(milestone.closed_items_count(guest)).to eq 2
end
- it 'should count confidential issues for author' do
+ it 'counts confidential issues for author' do
expect(milestone.closed_items_count(author)).to eq 4
end
- it 'should count confidential issues for assignee' do
+ it 'counts confidential issues for assignee' do
expect(milestone.closed_items_count(assignee)).to eq 4
end
- it 'should count confidential issues for project members' do
+ it 'counts confidential issues for project members' do
expect(milestone.closed_items_count(member)).to eq 6
end
- it 'should count all issues for admin' do
+ it 'counts all issues for admin' do
expect(milestone.closed_items_count(admin)).to eq 6
end
end
describe '#total_items_count' do
- it 'should not count confidential issues for non project members' do
+ it 'does not count confidential issues for non project members' do
expect(milestone.total_items_count(non_member)).to eq 4
end
- it 'should not count confidential issues for project members with guest role' do
+ it 'does not count confidential issues for project members with guest role' do
expect(milestone.total_items_count(guest)).to eq 4
end
- it 'should count confidential issues for author' do
+ it 'counts confidential issues for author' do
expect(milestone.total_items_count(author)).to eq 7
end
- it 'should count confidential issues for assignee' do
+ it 'counts confidential issues for assignee' do
expect(milestone.total_items_count(assignee)).to eq 7
end
- it 'should count confidential issues for project members' do
+ it 'counts confidential issues for project members' do
expect(milestone.total_items_count(member)).to eq 10
end
- it 'should count all issues for admin' do
+ it 'counts all issues for admin' do
expect(milestone.total_items_count(admin)).to eq 10
end
end
@@ -91,27 +91,27 @@ describe Milestone, 'Milestoneish' do
end
describe '#percent_complete' do
- it 'should not count confidential issues for non project members' do
+ it 'does not count confidential issues for non project members' do
expect(milestone.percent_complete(non_member)).to eq 50
end
- it 'should not count confidential issues for project members with guest role' do
+ it 'does not count confidential issues for project members with guest role' do
expect(milestone.percent_complete(guest)).to eq 50
end
- it 'should count confidential issues for author' do
+ it 'counts confidential issues for author' do
expect(milestone.percent_complete(author)).to eq 57
end
- it 'should count confidential issues for assignee' do
+ it 'counts confidential issues for assignee' do
expect(milestone.percent_complete(assignee)).to eq 57
end
- it 'should count confidential issues for project members' do
+ it 'counts confidential issues for project members' do
expect(milestone.percent_complete(member)).to eq 60
end
- it 'should count confidential issues for admin' do
+ it 'counts confidential issues for admin' do
expect(milestone.percent_complete(admin)).to eq 60
end
end
diff --git a/spec/models/concerns/token_authenticatable_spec.rb b/spec/models/concerns/token_authenticatable_spec.rb
index 9e8ebc56a31..eb64f3d0c83 100644
--- a/spec/models/concerns/token_authenticatable_spec.rb
+++ b/spec/models/concerns/token_authenticatable_spec.rb
@@ -41,7 +41,7 @@ describe ApplicationSetting, 'TokenAuthenticatable' do
describe 'ensured! token' do
subject { described_class.new.send("ensure_#{token_field}!") }
- it 'should persist new token' do
+ it 'persists new token' do
expect(subject).to eq described_class.current[token_field]
end
end
diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb
index f94987dcaff..9c81d159cdf 100644
--- a/spec/models/forked_project_link_spec.rb
+++ b/spec/models/forked_project_link_spec.rb
@@ -9,11 +9,11 @@ describe ForkedProjectLink, "add link on fork" do
@project_to = fork_project(project_from, user)
end
- it "project_to should know it is forked" do
+ it "project_to knows it is forked" do
expect(@project_to.forked?).to be_truthy
end
- it "project should know who it is forked from" do
+ it "project knows who it is forked from" do
expect(@project_to.forked_from_project).to eq(project_from)
end
end
@@ -29,15 +29,15 @@ describe '#forked?' do
forked_project_link.save!
end
- it "project_to should know it is forked" do
+ it "project_to knows it is forked" do
expect(project_to.forked?).to be_truthy
end
- it "project_from should not be forked" do
+ it "project_from is not forked" do
expect(project_from.forked?).to be_falsey
end
- it "project_to.destroy should destroy fork_link" do
+ it "project_to.destroy destroys fork_link" do
expect(forked_project_link).to receive(:destroy)
project_to.destroy
end
diff --git a/spec/models/global_milestone_spec.rb b/spec/models/global_milestone_spec.rb
index ae77ec5b348..92e0f7f27ce 100644
--- a/spec/models/global_milestone_spec.rb
+++ b/spec/models/global_milestone_spec.rb
@@ -29,15 +29,15 @@ describe GlobalMilestone, models: true do
@global_milestones = GlobalMilestone.build_collection(milestones)
end
- it 'should have all project milestones' do
+ it 'has all project milestones' do
expect(@global_milestones.count).to eq(2)
end
- it 'should have all project milestones titles' do
+ it 'has all project milestones titles' do
expect(@global_milestones.map(&:title)).to match_array(['Milestone v1.2', 'VD-123'])
end
- it 'should have all project milestones' do
+ it 'has all project milestones' do
expect(@global_milestones.map { |group_milestone| group_milestone.milestones.count }.sum).to eq(6)
end
end
@@ -54,11 +54,11 @@ describe GlobalMilestone, models: true do
@global_milestone = GlobalMilestone.new(milestone1_project1.title, milestones)
end
- it 'should have exactly one group milestone' do
+ it 'has exactly one group milestone' do
expect(@global_milestone.title).to eq('Milestone v1.2')
end
- it 'should have all project milestones with the same title' do
+ it 'has all project milestones with the same title' do
expect(@global_milestone.milestones.count).to eq(3)
end
end
@@ -66,7 +66,7 @@ describe GlobalMilestone, models: true do
describe '#safe_title' do
let(:milestone) { create(:milestone, title: "git / test", project: project1) }
- it 'should strip out slashes and spaces' do
+ it 'strips out slashes and spaces' do
global_milestone = GlobalMilestone.new(milestone.title, [milestone])
expect(global_milestone.safe_title).to eq('git-test')
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 266c46213a6..ea4b59c26b1 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -116,7 +116,7 @@ describe Group, models: true do
let(:user) { create(:user) }
before { group.add_users([user.id], GroupMember::GUEST) }
- it "should update the group permission" do
+ it "updates the group permission" do
expect(group.group_members.guests.map(&:user)).to include(user)
group.add_users([user.id], GroupMember::DEVELOPER)
expect(group.group_members.developers.map(&:user)).to include(user)
@@ -128,12 +128,12 @@ describe Group, models: true do
let(:user) { create(:user) }
before { group.add_user(user, GroupMember::MASTER) }
- it "should be true if avatar is image" do
+ it "is true if avatar is image" do
group.update_attribute(:avatar, 'uploads/avatar.png')
expect(group.avatar_type).to be_truthy
end
- it "should be false if avatar is html page" do
+ it "is false if avatar is html page" do
group.update_attribute(:avatar, 'uploads/avatar.html')
expect(group.avatar_type).to eq(["only images allowed"])
end
diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb
index 983848392b7..4a457997a4f 100644
--- a/spec/models/hooks/project_hook_spec.rb
+++ b/spec/models/hooks/project_hook_spec.rb
@@ -24,7 +24,7 @@ describe ProjectHook, models: true do
end
describe '.push_hooks' do
- it 'should return hooks for push events only' do
+ it 'returns hooks for push events only' do
hook = create(:project_hook, push_events: true)
create(:project_hook, push_events: false)
expect(ProjectHook.push_hooks).to eq([hook])
@@ -32,7 +32,7 @@ describe ProjectHook, models: true do
end
describe '.tag_push_hooks' do
- it 'should return hooks for tag push events only' do
+ it 'returns hooks for tag push events only' do
hook = create(:project_hook, tag_push_events: true)
create(:project_hook, tag_push_events: false)
expect(ProjectHook.tag_push_hooks).to eq([hook])
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 6d68e52a822..fd4a2beff58 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -73,13 +73,13 @@ describe Key, models: true do
end
context 'callbacks' do
- it 'should add new key to authorized_file' do
+ it 'adds new key to authorized_file' do
@key = build(:personal_key, id: 7)
expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
@key.save
end
- it 'should remove key from authorized_file' do
+ it 'removes key from authorized_file' do
@key = create(:personal_key)
expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
@key.destroy
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index f37f44a608e..2a09063f857 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -18,7 +18,7 @@ describe Label, models: true do
describe 'validation' do
it { is_expected.to validate_presence_of(:project) }
- it 'should validate color code' do
+ it 'validates color code' do
expect(label).not_to allow_value('G-ITLAB').for(:color)
expect(label).not_to allow_value('AABBCC').for(:color)
expect(label).not_to allow_value('#AABBCCEE').for(:color)
@@ -30,7 +30,7 @@ describe Label, models: true do
expect(label).to allow_value('#abcdef').for(:color)
end
- it 'should validate title' do
+ it 'validates title' do
expect(label).not_to allow_value('G,ITLAB').for(:title)
expect(label).not_to allow_value('').for(:title)
diff --git a/spec/models/legacy_diff_note_spec.rb b/spec/models/legacy_diff_note_spec.rb
index c8ee656fe3b..2cfd26419ca 100644
--- a/spec/models/legacy_diff_note_spec.rb
+++ b/spec/models/legacy_diff_note_spec.rb
@@ -5,12 +5,12 @@ describe LegacyDiffNote, models: true do
let!(:note) { create(:legacy_diff_note_on_commit, note: "+1 from me") }
let!(:commit) { note.noteable }
- it "should save a valid note" do
+ it "saves a valid note" do
expect(note.commit_id).to eq(commit.id)
expect(note.noteable.id).to eq(commit.id)
end
- it "should be recognized by #legacy_diff_note?" do
+ it "is recognized by #legacy_diff_note?" do
expect(note).to be_legacy_diff_note
end
end
diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb
index 18439cac2a4..4f875fd257a 100644
--- a/spec/models/members/group_member_spec.rb
+++ b/spec/models/members/group_member_spec.rb
@@ -22,7 +22,7 @@ require 'spec_helper'
describe GroupMember, models: true do
describe 'notifications' do
describe "#after_create" do
- it "should send email to user" do
+ it "sends email to user" do
membership = build(:group_member)
allow(membership).to receive(:notification_service).
@@ -40,7 +40,7 @@ describe GroupMember, models: true do
and_return(double('NotificationService').as_null_object)
end
- it "should send email to user" do
+ it "sends email to user" do
expect(@group_member).to receive(:notification_service)
@group_member.update_attribute(:access_level, GroupMember::MASTER)
end
diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb
index ba622dfb9be..28673de3189 100644
--- a/spec/models/members/project_member_spec.rb
+++ b/spec/models/members/project_member_spec.rb
@@ -52,7 +52,7 @@ describe ProjectMember, models: true do
master_todos
end
- it "destroy itself and delete associated todos" do
+ it "destroys itself and delete associated todos" do
expect(owner.user.todos.size).to eq(2)
expect(master.user.todos.size).to eq(3)
expect(Todo.count).to eq(5)
@@ -101,7 +101,7 @@ describe ProjectMember, models: true do
end
end
- describe '.add_users_into_projects' do
+ describe '.add_users_to_projects' do
before do
@project_1 = create :project
@project_2 = create :project
@@ -109,7 +109,7 @@ describe ProjectMember, models: true do
@user_1 = create :user
@user_2 = create :user
- ProjectMember.add_users_into_projects(
+ ProjectMember.add_users_to_projects(
[@project_1.id, @project_2.id],
[@user_1.id, @user_2.id],
ProjectMember::MASTER
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index d793cfd0bde..3270b877c1a 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -188,12 +188,12 @@ describe MergeRequest, models: true do
create(:note, noteable: merge_request, project: merge_request.project)
end
- it "should include notes for commits" do
+ it "includes notes for commits" do
expect(merge_request.commits).not_to be_empty
expect(merge_request.mr_and_commit_notes.count).to eq(2)
end
- it "should include notes for commits from target project as well" do
+ it "includes notes for commits from target project as well" do
create(:note_on_commit, commit_id: merge_request.commits.first.id,
project: merge_request.target_project)
@@ -304,7 +304,7 @@ describe MergeRequest, models: true do
expect(subject.can_remove_source_branch?(user)).to be_falsey
end
- it "cant remove a root ref" do
+ it "can't remove a root ref" do
subject.source_branch = "master"
subject.target_branch = "feature"
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index d661dc0e59a..d64d6cde2b5 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -28,12 +28,12 @@ describe Milestone, models: true do
end
describe "unique milestone title per project" do
- it "shouldn't accept the same title in a project twice" do
+ it "does not accept the same title in a project twice" do
new_milestone = Milestone.new(project: milestone.project, title: milestone.title)
expect(new_milestone).not_to be_valid
end
- it "should accept the same title in another project" do
+ it "accepts the same title in another project" do
project = build(:project)
new_milestone = Milestone.new(project: project, title: milestone.title)
@@ -42,29 +42,29 @@ describe Milestone, models: true do
end
describe "#percent_complete" do
- it "should not count open issues" do
+ it "does not count open issues" do
milestone.issues << issue
expect(milestone.percent_complete(user)).to eq(0)
end
- it "should count closed issues" do
+ it "counts closed issues" do
issue.close
milestone.issues << issue
expect(milestone.percent_complete(user)).to eq(100)
end
- it "should recover from dividing by zero" do
+ it "recovers from dividing by zero" do
expect(milestone.percent_complete(user)).to eq(0)
end
end
describe "#expires_at" do
- it "should be nil when due_date is unset" do
+ it "is nil when due_date is unset" do
milestone.update_attributes(due_date: nil)
expect(milestone.expires_at).to be_nil
end
- it "should not be nil when due_date is set" do
+ it "is not nil when due_date is set" do
milestone.update_attributes(due_date: Date.tomorrow)
expect(milestone.expires_at).to be_present
end
@@ -121,7 +121,7 @@ describe Milestone, models: true do
create :merge_request, milestone: milestone
end
- it 'Should return total count of issues and merge requests assigned to milestone' do
+ it 'returns total count of issues and merge requests assigned to milestone' do
expect(milestone.total_items_count(user)).to eq 2
end
end
@@ -134,11 +134,11 @@ describe Milestone, models: true do
create :issue
end
- it 'should be true if milestone active and all nested issues closed' do
+ it 'returns true if milestone active and all nested issues closed' do
expect(milestone.can_be_closed?).to be_truthy
end
- it 'should be false if milestone active and not all nested issues closed' do
+ it 'returns false if milestone active and not all nested issues closed' do
issue.milestone = milestone
issue.save
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index a162da0208e..544920d1824 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -61,11 +61,11 @@ describe Namespace, models: true do
allow(@namespace).to receive(:path_changed?).and_return(true)
end
- it "should raise error when directory exists" do
+ it "raises error when directory exists" do
expect { @namespace.move_dir }.to raise_error("namespace directory cannot be moved")
end
- it "should move dir if path changed" do
+ it "moves dir if path changed" do
new_path = @namespace.path + "_new"
allow(@namespace).to receive(:path_was).and_return(@namespace.path)
allow(@namespace).to receive(:path).and_return(new_path)
@@ -93,7 +93,7 @@ describe Namespace, models: true do
before { namespace.destroy }
- it "should remove its dirs when deleted" do
+ it "removes its dirs when deleted" do
expect(File.exist?(path)).to be(false)
end
end
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 1243f5420a7..53733d253f7 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -56,18 +56,18 @@ describe Note, models: true do
let!(:note) { create(:note_on_commit, note: "+1 from me") }
let!(:commit) { note.noteable }
- it "should be accessible through #noteable" do
+ it "is accessible through #noteable" do
expect(note.commit_id).to eq(commit.id)
expect(note.noteable).to be_a(Commit)
expect(note.noteable).to eq(commit)
end
- it "should save a valid note" do
+ it "saves a valid note" do
expect(note.commit_id).to eq(commit.id)
note.noteable == commit
end
- it "should be recognized by #for_commit?" do
+ it "is recognized by #for_commit?" do
expect(note).to be_for_commit
end
diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb
index 2142c7c13ef..36379074ea0 100644
--- a/spec/models/project_security_spec.rb
+++ b/spec/models/project_security_spec.rb
@@ -21,7 +21,7 @@ describe Project, models: true do
let(:owner_actions) { Ability.project_owner_rules }
describe "Non member rules" do
- it "should deny for non-project users any actions" do
+ it "denies for non-project users any actions" do
owner_actions.each do |action|
expect(@abilities.allowed?(@u1, action, @p1)).to be_falsey
end
@@ -33,7 +33,7 @@ describe Project, models: true do
@p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::GUEST)
end
- it "should allow for project user any guest actions" do
+ it "allows for project user any guest actions" do
guest_actions.each do |action|
expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy
end
@@ -45,7 +45,7 @@ describe Project, models: true do
@p1.project_members.create(project: @p1, user: @u2, access_level: ProjectMember::REPORTER)
end
- it "should allow for project user any report actions" do
+ it "allows for project user any report actions" do
report_actions.each do |action|
expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy
end
@@ -58,13 +58,13 @@ describe Project, models: true do
@p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::DEVELOPER)
end
- it "should deny for developer master-specific actions" do
+ it "denies for developer master-specific actions" do
[dev_actions - report_actions].each do |action|
expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
end
end
- it "should allow for project user any dev actions" do
+ it "allows for project user any dev actions" do
dev_actions.each do |action|
expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy
end
@@ -77,13 +77,13 @@ describe Project, models: true do
@p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER)
end
- it "should deny for developer master-specific actions" do
+ it "denies for developer master-specific actions" do
[master_actions - dev_actions].each do |action|
expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
end
end
- it "should allow for project user any master actions" do
+ it "allows for project user any master actions" do
master_actions.each do |action|
expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy
end
@@ -96,13 +96,13 @@ describe Project, models: true do
@p1.project_members.create(project: @p1, user: @u3, access_level: ProjectMember::MASTER)
end
- it "should deny for masters admin-specific actions" do
+ it "denies for masters admin-specific actions" do
[owner_actions - master_actions].each do |action|
expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
end
end
- it "should allow for project owner any admin actions" do
+ it "allows for project owner any admin actions" do
owner_actions.each do |action|
expect(@abilities.allowed?(@u4, action, @p1)).to be_truthy
end
diff --git a/spec/models/project_services/asana_service_spec.rb b/spec/models/project_services/asana_service_spec.rb
index f3d15f3c1ea..dc702cfc42c 100644
--- a/spec/models/project_services/asana_service_spec.rb
+++ b/spec/models/project_services/asana_service_spec.rb
@@ -65,7 +65,7 @@ describe AsanaService, models: true do
)
end
- it 'should call Asana service to create a story' do
+ it 'calls Asana service to create a story' do
data = create_data_for_commits('Message from commit. related to #123456')
expected_message = "#{data[:user_name]} pushed to branch #{data[:ref]} of #{project.name_with_namespace} ( #{data[:commits][0][:url]} ): #{data[:commits][0][:message]}"
@@ -76,7 +76,7 @@ describe AsanaService, models: true do
@asana.execute(data)
end
- it 'should call Asana service to create a story and close a task' do
+ it 'calls Asana service to create a story and close a task' do
data = create_data_for_commits('fix #456789')
d1 = double('Asana::Task')
expect(d1).to receive(:add_comment)
@@ -86,7 +86,7 @@ describe AsanaService, models: true do
@asana.execute(data)
end
- it 'should be able to close via url' do
+ it 'is able to close via url' do
data = create_data_for_commits('closes https://app.asana.com/19292/956299/42')
d1 = double('Asana::Task')
expect(d1).to receive(:add_comment)
@@ -96,7 +96,7 @@ describe AsanaService, models: true do
@asana.execute(data)
end
- it 'should allow multiple matches per line' do
+ it 'allows multiple matches per line' do
message = <<-EOF
minor bigfix, refactoring, fixed #123 and Closes #456 work on #789
ref https://app.asana.com/19292/956299/42 and closing https://app.asana.com/19292/956299/12
diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb
index 63d1c4ce845..d20decc13a7 100644
--- a/spec/models/project_services/assembla_service_spec.rb
+++ b/spec/models/project_services/assembla_service_spec.rb
@@ -45,7 +45,7 @@ describe AssemblaService, models: true do
WebMock.stub_request(:post, @api_url)
end
- it "should call Assembla API" do
+ it "calls Assembla API" do
@assembla_service.execute(@sample_data)
expect(WebMock).to have_requested(:post, @api_url).with(
body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
diff --git a/spec/models/project_services/external_wiki_service_spec.rb b/spec/models/project_services/external_wiki_service_spec.rb
index 5fe5ea7d2df..d7c5ea95d71 100644
--- a/spec/models/project_services/external_wiki_service_spec.rb
+++ b/spec/models/project_services/external_wiki_service_spec.rb
@@ -56,7 +56,7 @@ describe ExternalWikiService, models: true do
@service.destroy!
end
- it 'should replace the wiki url' do
+ it 'replaces the wiki url' do
wiki_path = get_project_wiki_path(project)
expect(wiki_path).to match('https://gitlab.com')
end
diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb
index a021f82b374..1f00562fa05 100644
--- a/spec/models/project_services/flowdock_service_spec.rb
+++ b/spec/models/project_services/flowdock_service_spec.rb
@@ -58,7 +58,7 @@ describe FlowdockService, models: true do
WebMock.stub_request(:post, @api_url)
end
- it "should call FlowDock API" do
+ it "calls FlowDock API" do
@flowdock_service.execute(@sample_data)
@sample_data[:commits].each do |commit|
# One request to Flowdock per new commit
diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb
index 39ce8ee3387..5940e44e57d 100644
--- a/spec/models/project_services/gemnasium_service_spec.rb
+++ b/spec/models/project_services/gemnasium_service_spec.rb
@@ -58,7 +58,7 @@ describe GemnasiumService, models: true do
@sample_data = Gitlab::DataBuilder::PushDataBuilder.
build_sample(project, user)
end
- it "should call Gemnasium service" do
+ it "calls Gemnasium service" do
expect(Gemnasium::GitlabService).to receive(:execute).with(an_instance_of(Hash)).once
@gemnasium_service.execute(@sample_data)
end
diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
index 7a1f106d6e3..8ef79a17d50 100644
--- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
@@ -54,7 +54,7 @@ describe GitlabIssueTrackerService, models: true do
@service.destroy!
end
- it 'should give the correct path' do
+ it 'gives the correct path' do
expect(@service.project_url).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues")
expect(@service.new_issue_url).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues/new")
expect(@service.issue_url(432)).to eq("http://localhost/gitlab/root/#{project.path_with_namespace}/issues/432")
@@ -71,7 +71,7 @@ describe GitlabIssueTrackerService, models: true do
@service.destroy!
end
- it 'should give the correct path' do
+ it 'gives the correct path' do
expect(@service.project_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues")
expect(@service.new_issue_path).to eq("/gitlab/root/#{project.path_with_namespace}/issues/new")
expect(@service.issue_path(432)).to eq("/gitlab/root/#{project.path_with_namespace}/issues/432")
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
index 987e4359446..bb6c75d6050 100644
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ b/spec/models/project_services/hipchat_service_spec.rb
@@ -63,7 +63,7 @@ describe HipchatService, models: true do
WebMock.stub_request(:post, api_url)
end
- it 'should test and return errors' do
+ it 'tests and return errors' do
allow(hipchat).to receive(:execute).and_raise(StandardError, 'no such room')
result = hipchat.test(push_sample_data)
@@ -71,7 +71,7 @@ describe HipchatService, models: true do
expect(result[:result].to_s).to eq('no such room')
end
- it 'should use v1 if version is provided' do
+ it 'uses v1 if version is provided' do
allow(hipchat).to receive(:api_version).and_return('v1')
expect(HipChat::Client).to receive(:new).with(
token,
@@ -81,7 +81,7 @@ describe HipchatService, models: true do
hipchat.execute(push_sample_data)
end
- it 'should use v2 as the version when nothing is provided' do
+ it 'uses v2 as the version when nothing is provided' do
allow(hipchat).to receive(:api_version).and_return('')
expect(HipChat::Client).to receive(:new).with(
token,
@@ -92,13 +92,13 @@ describe HipchatService, models: true do
end
context 'push events' do
- it "should call Hipchat API for push events" do
+ it "calls Hipchat API for push events" do
hipchat.execute(push_sample_data)
expect(WebMock).to have_requested(:post, api_url).once
end
- it "should create a push message" do
+ it "creates a push message" do
message = hipchat.send(:create_push_message, push_sample_data)
push_sample_data[:object_attributes]
@@ -120,13 +120,13 @@ describe HipchatService, models: true do
[])
end
- it "should call Hipchat API for tag push events" do
+ it "calls Hipchat API for tag push events" do
hipchat.execute(push_sample_data)
expect(WebMock).to have_requested(:post, api_url).once
end
- it "should create a tag push message" do
+ it "creates a tag push message" do
message = hipchat.send(:create_push_message, push_sample_data)
push_sample_data[:object_attributes]
@@ -141,13 +141,13 @@ describe HipchatService, models: true do
let(:issue_service) { Issues::CreateService.new(project, user) }
let(:issues_sample_data) { issue_service.hook_data(issue, 'open') }
- it "should call Hipchat API for issue events" do
+ it "calls Hipchat API for issue events" do
hipchat.execute(issues_sample_data)
expect(WebMock).to have_requested(:post, api_url).once
end
- it "should create an issue message" do
+ it "creates an issue message" do
message = hipchat.send(:create_issue_message, issues_sample_data)
obj_attr = issues_sample_data[:object_attributes]
@@ -164,13 +164,13 @@ describe HipchatService, models: true do
let(:merge_service) { MergeRequests::CreateService.new(project, user) }
let(:merge_sample_data) { merge_service.hook_data(merge_request, 'open') }
- it "should call Hipchat API for merge requests events" do
+ it "calls Hipchat API for merge requests events" do
hipchat.execute(merge_sample_data)
expect(WebMock).to have_requested(:post, api_url).once
end
- it "should create a merge request message" do
+ it "creates a merge request message" do
message = hipchat.send(:create_merge_request_message,
merge_sample_data)
@@ -194,7 +194,7 @@ describe HipchatService, models: true do
note: 'a comment on a commit')
end
- it "should call Hipchat API for commit comment events" do
+ it "calls Hipchat API for commit comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.build(commit_note, user)
hipchat.execute(data)
@@ -226,7 +226,7 @@ describe HipchatService, models: true do
note: "merge request note")
end
- it "should call Hipchat API for merge request comment events" do
+ it "calls Hipchat API for merge request comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.build(merge_request_note, user)
hipchat.execute(data)
@@ -253,7 +253,7 @@ describe HipchatService, models: true do
note: "issue note")
end
- it "should call Hipchat API for issue comment events" do
+ it "calls Hipchat API for issue comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.build(issue_note, user)
hipchat.execute(data)
@@ -279,7 +279,7 @@ describe HipchatService, models: true do
note: "snippet note")
end
- it "should call Hipchat API for snippet comment events" do
+ it "calls Hipchat API for snippet comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.build(snippet_note, user)
hipchat.execute(data)
@@ -308,13 +308,13 @@ describe HipchatService, models: true do
context 'for failed' do
before { build.drop }
- it "should call Hipchat API" do
+ it "calls Hipchat API" do
hipchat.execute(data)
expect(WebMock).to have_requested(:post, api_url).once
end
- it "should create a build message" do
+ it "creates a build message" do
message = hipchat.send(:create_build_message, data)
project_url = project.web_url
@@ -336,13 +336,13 @@ describe HipchatService, models: true do
build.success
end
- it "should call Hipchat API" do
+ it "calls Hipchat API" do
hipchat.notify_only_broken_builds = false
hipchat.execute(data)
expect(WebMock).to have_requested(:post, api_url).once
end
- it "should notify only broken" do
+ it "notifies only broken" do
hipchat.notify_only_broken_builds = true
hipchat.execute(data)
expect(WebMock).not_to have_requested(:post, api_url).once
diff --git a/spec/models/project_services/irker_service_spec.rb b/spec/models/project_services/irker_service_spec.rb
index d49948e693d..646f0d54424 100644
--- a/spec/models/project_services/irker_service_spec.rb
+++ b/spec/models/project_services/irker_service_spec.rb
@@ -73,7 +73,7 @@ describe IrkerService, models: true do
@irker_server.close
end
- it 'should send valid JSON messages to an Irker listener' do
+ it 'sends valid JSON messages to an Irker listener' do
irker.execute(sample_data)
conn = @irker_server.accept
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 13aec5172e9..88800bb61d4 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -76,7 +76,7 @@ describe JiraService, models: true do
WebMock.stub_request(:post, @comment_url)
end
- it "should call JIRA API" do
+ it "calls JIRA API" do
@jira_service.execute(merge_request,
ExternalIssue.new("JIRA-123", project))
expect(WebMock).to have_requested(:post, @comment_url).with(
@@ -129,7 +129,7 @@ describe JiraService, models: true do
expect(@jira_service.api_url).to eq("http://jira_edited.example.com/rest/api/2")
end
- it "should reset password if url changed, even if setter called multiple times" do
+ it "resets password if url changed, even if setter called multiple times" do
@jira_service.api_url = 'http://jira1.example.com/rest/api/2'
@jira_service.api_url = 'http://jira1.example.com/rest/api/2'
@jira_service.save
@@ -182,7 +182,7 @@ describe JiraService, models: true do
@service.destroy!
end
- it 'should be initialized' do
+ it 'is initialized' do
expect(@service.title).to eq('JIRA')
expect(@service.description).to eq("Jira issue tracker")
end
@@ -198,7 +198,7 @@ describe JiraService, models: true do
@service.destroy!
end
- it "should be correct" do
+ it "is correct" do
expect(@service.title).to eq('Jira One')
expect(@service.description).to eq('Jira One issue tracker')
end
@@ -226,7 +226,7 @@ describe JiraService, models: true do
@service.destroy!
end
- it 'should be prepopulated with the settings' do
+ it 'is prepopulated with the settings' do
expect(@service.properties["project_url"]).to eq('http://jira.sample/projects/project_a')
expect(@service.properties["issues_url"]).to eq("http://jira.sample/issues/:id")
expect(@service.properties["new_issue_url"]).to eq("http://jira.sample/projects/project_a/issues/new")
diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb
index 8c0141b4788..f1a245ead2c 100644
--- a/spec/models/project_services/pushover_service_spec.rb
+++ b/spec/models/project_services/pushover_service_spec.rb
@@ -74,7 +74,7 @@ describe PushoverService, models: true do
WebMock.stub_request(:post, api_url)
end
- it 'should call Pushover API' do
+ it 'calls Pushover API' do
pushover.execute(sample_data)
expect(WebMock).to have_requested(:post, api_url).once
diff --git a/spec/models/project_services/slack_service/note_message_spec.rb b/spec/models/project_services/slack_service/note_message_spec.rb
index 379c3e1219c..41b93f08050 100644
--- a/spec/models/project_services/slack_service/note_message_spec.rb
+++ b/spec/models/project_services/slack_service/note_message_spec.rb
@@ -60,6 +60,7 @@ describe SlackService::NoteMessage, models: true do
title: "merge request title\ndetails\n"
}
end
+
it 'returns a message regarding notes on a merge request' do
message = SlackService::NoteMessage.new(@args)
expect(message.pretext).to eq("Test User commented on " \
diff --git a/spec/models/project_services/slack_service/wiki_page_message_spec.rb b/spec/models/project_services/slack_service/wiki_page_message_spec.rb
index 46dedb66c7c..13aea0b0600 100644
--- a/spec/models/project_services/slack_service/wiki_page_message_spec.rb
+++ b/spec/models/project_services/slack_service/wiki_page_message_spec.rb
@@ -47,7 +47,7 @@ describe SlackService::WikiPageMessage, models: true do
context 'when :action == "create"' do
before { args[:object_attributes][:action] = 'create' }
- it 'it returns the attachment for a new wiki page' do
+ it 'returns the attachment for a new wiki page' do
expect(subject.attachments).to eq([
{
text: "Wiki page description",
@@ -60,7 +60,7 @@ describe SlackService::WikiPageMessage, models: true do
context 'when :action == "update"' do
before { args[:object_attributes][:action] = 'update' }
- it 'it returns the attachment for an updated wiki page' do
+ it 'returns the attachment for an updated wiki page' do
expect(subject.attachments).to eq([
{
text: "Wiki page description",
diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb
index 8b15024de7b..3bbe4473b12 100644
--- a/spec/models/project_services/slack_service_spec.rb
+++ b/spec/models/project_services/slack_service_spec.rb
@@ -95,31 +95,31 @@ describe SlackService, models: true do
@wiki_page_sample_data = wiki_page_service.hook_data(@wiki_page, 'create')
end
- it "should call Slack API for push events" do
+ it "calls Slack API for push events" do
slack.execute(push_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
- it "should call Slack API for issue events" do
+ it "calls Slack API for issue events" do
slack.execute(@issues_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
- it "should call Slack API for merge requests events" do
+ it "calls Slack API for merge requests events" do
slack.execute(@merge_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
- it "should call Slack API for wiki page events" do
+ it "calls Slack API for wiki page events" do
slack.execute(@wiki_page_sample_data)
expect(WebMock).to have_requested(:post, webhook_url).once
end
- it 'should use the username as an option for slack when configured' do
+ it 'uses the username as an option for slack when configured' do
allow(slack).to receive(:username).and_return(username)
expect(Slack::Notifier).to receive(:new).
with(webhook_url, username: username).
@@ -130,7 +130,7 @@ describe SlackService, models: true do
slack.execute(push_sample_data)
end
- it 'should use the channel as an option when it is configured' do
+ it 'uses the channel as an option when it is configured' do
allow(slack).to receive(:channel).and_return(channel)
expect(Slack::Notifier).to receive(:new).
with(webhook_url, channel: channel).
@@ -237,8 +237,13 @@ describe SlackService, models: true do
note: 'a comment on a commit')
end
+<<<<<<< HEAD
it "should call Slack API for commit comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.build(commit_note, user)
+=======
+ it "calls Slack API for commit comment events" do
+ data = Gitlab::NoteDataBuilder.build(commit_note, user)
+>>>>>>> refactor-builds-creation-service
slack.execute(data)
expect(WebMock).to have_requested(:post, webhook_url).once
@@ -251,7 +256,7 @@ describe SlackService, models: true do
note: "merge request note")
end
- it "should call Slack API for merge request comment events" do
+ it "calls Slack API for merge request comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.
build(merge_request_note, user)
slack.execute(data)
@@ -265,7 +270,7 @@ describe SlackService, models: true do
create(:note_on_issue, project: project, note: "issue note")
end
- it "should call Slack API for issue comment events" do
+ it "calls Slack API for issue comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.build(issue_note, user)
slack.execute(data)
@@ -279,7 +284,7 @@ describe SlackService, models: true do
note: "snippet note")
end
- it "should call Slack API for snippet comment events" do
+ it "calls Slack API for snippet comment events" do
data = Gitlab::DataBuilder::NoteDataBuilder.build(snippet_note, user)
slack.execute(data)
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index e365e4e98b2..1c3d694075a 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -69,6 +69,7 @@ describe Project, models: true do
it { is_expected.to include_module(Gitlab::ConfigHelper) }
it { is_expected.to include_module(Gitlab::ShellAdapter) }
it { is_expected.to include_module(Gitlab::VisibilityLevel) }
+ it { is_expected.to include_module(Gitlab::CurrentSettings) }
it { is_expected.to include_module(Referable) }
it { is_expected.to include_module(Sortable) }
end
@@ -88,7 +89,7 @@ describe Project, models: true do
it { is_expected.to validate_presence_of(:namespace) }
it { is_expected.to validate_presence_of(:repository_storage) }
- it 'should not allow new projects beyond user limits' do
+ it 'does not allow new projects beyond user limits' do
project2 = build(:project)
allow(project2).to receive(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object)
expect(project2).not_to be_valid
@@ -97,7 +98,7 @@ describe Project, models: true do
describe 'wiki path conflict' do
context "when the new path has been used by the wiki of other Project" do
- it 'should have an error on the name attribute' do
+ it 'has an error on the name attribute' do
new_project = build_stubbed(:project, namespace_id: project.namespace_id, path: "#{project.path}.wiki")
expect(new_project).not_to be_valid
@@ -106,7 +107,7 @@ describe Project, models: true do
end
context "when the new wiki path has been used by the path of other Project" do
- it 'should have an error on the name attribute' do
+ it 'has an error on the name attribute' do
project_with_wiki_suffix = create(:project, path: 'foo.wiki')
new_project = build_stubbed(:project, namespace_id: project_with_wiki_suffix.namespace_id, path: 'foo')
@@ -124,7 +125,7 @@ describe Project, models: true do
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
- it "should not allow repository storages that don't match a label in the configuration" do
+ it "does not allow repository storages that don't match a label in the configuration" do
expect(project2).not_to be_valid
expect(project2.errors[:repository_storage].first).to match(/is not included in the list/)
end
@@ -171,12 +172,12 @@ describe Project, models: true do
end
describe 'project token' do
- it 'should set an random token if none provided' do
+ it 'sets an random token if none provided' do
project = FactoryGirl.create :empty_project, runners_token: ''
expect(project.runners_token).not_to eq('')
end
- it 'should not set an random toke if one provided' do
+ it 'does not set an random toke if one provided' do
project = FactoryGirl.create :empty_project, runners_token: 'my-token'
expect(project.runners_token).to eq('my-token')
end
@@ -224,7 +225,7 @@ describe Project, models: true do
end
end
- it 'should return valid url to repo' do
+ it 'returns valid url to repo' do
project = Project.new(path: 'somewhere')
expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git')
end
@@ -278,7 +279,7 @@ describe Project, models: true do
let(:last_event) { double(created_at: Time.now) }
describe 'last_activity' do
- it 'should alias last_activity to last_event' do
+ it 'alias last_activity to last_event' do
allow(project).to receive(:last_event).and_return(last_event)
expect(project.last_activity).to eq(last_event)
end
@@ -349,13 +350,13 @@ describe Project, models: true do
let(:prev_commit_id) { merge_request.commits.last.id }
let(:commit_id) { merge_request.commits.first.id }
- it 'should close merge request if last commit from source branch was pushed to target branch' do
+ it 'closes merge request if last commit from source branch was pushed to target branch' do
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.target_branch}", key.user)
merge_request.reload
expect(merge_request.merged?).to be_truthy
end
- it 'should update merge request commits with new one if pushed to source branch' do
+ it 'updates merge request commits with new one if pushed to source branch' do
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.source_branch}", key.user)
merge_request.reload
expect(merge_request.diff_head_sha).to eq(commit_id)
@@ -432,11 +433,11 @@ describe Project, models: true do
let(:project) { create(:project) }
let(:ext_project) { create(:redmine_project) }
- it "should be true if used internal tracker" do
+ it "is true if used internal tracker" do
expect(project.default_issues_tracker?).to be_truthy
end
- it "should be false if used other tracker" do
+ it "is false if used other tracker" do
expect(ext_project.default_issues_tracker?).to be_falsey
end
end
@@ -635,12 +636,12 @@ describe Project, models: true do
describe '#avatar_type' do
let(:project) { create(:project) }
- it 'should be true if avatar is image' do
+ it 'is true if avatar is image' do
project.update_attribute(:avatar, 'uploads/avatar.png')
expect(project.avatar_type).to be_truthy
end
- it 'should be false if avatar is html page' do
+ it 'is false if avatar is html page' do
project.update_attribute(:avatar, 'uploads/avatar.html')
expect(project.avatar_type).to eq(['only images allowed'])
end
@@ -813,16 +814,16 @@ describe Project, models: true do
context 'for shared runners disabled' do
let(:shared_runners_enabled) { false }
- it 'there are no runners available' do
+ it 'has no runners available' do
expect(project.any_runners?).to be_falsey
end
- it 'there is a specific runner' do
+ it 'has a specific runner' do
project.runners << specific_runner
expect(project.any_runners?).to be_truthy
end
- it 'there is a shared runner, but they are prohibited to use' do
+ it 'has a shared runner, but they are prohibited to use' do
shared_runner
expect(project.any_runners?).to be_falsey
end
@@ -836,7 +837,7 @@ describe Project, models: true do
context 'for shared runners enabled' do
let(:shared_runners_enabled) { true }
- it 'there is a shared runner' do
+ it 'has a shared runner' do
shared_runner
expect(project.any_runners?).to be_truthy
end
@@ -1070,28 +1071,97 @@ describe Project, models: true do
end
describe '#protected_branch?' do
+ context 'existing project' do
+ let(:project) { create(:project) }
+
+ it 'returns true when the branch matches a protected branch via direct match' do
+ project.protected_branches.create!(name: 'foo')
+
+ expect(project.protected_branch?('foo')).to eq(true)
+ end
+
+ it 'returns true when the branch matches a protected branch via wildcard match' do
+ project.protected_branches.create!(name: 'production/*')
+
+ expect(project.protected_branch?('production/some-branch')).to eq(true)
+ end
+
+ it 'returns false when the branch does not match a protected branch via direct match' do
+ expect(project.protected_branch?('foo')).to eq(false)
+ end
+
+ it 'returns false when the branch does not match a protected branch via wildcard match' do
+ project.protected_branches.create!(name: 'production/*')
+
+ expect(project.protected_branch?('staging/some-branch')).to eq(false)
+ end
+ end
+
+ context "new project" do
+ let(:project) { create(:empty_project) }
+
+ it 'returns false when default_protected_branch is unprotected' do
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
+
+ expect(project.protected_branch?('master')).to be false
+ end
+
+ it 'returns false when default_protected_branch lets developers push' do
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
+
+ expect(project.protected_branch?('master')).to be false
+ end
+
+ it 'returns true when default_branch_protection does not let developers push but let developer merge branches' do
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
+
+ expect(project.protected_branch?('master')).to be true
+ end
+
+ it 'returns true when default_branch_protection is in full protection' do
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_FULL)
+
+ expect(project.protected_branch?('master')).to be true
+ end
+ end
+ end
+
+ describe '#user_can_push_to_empty_repo?' do
let(:project) { create(:empty_project) }
+ let(:user) { create(:user) }
- it 'returns true when the branch matches a protected branch via direct match' do
- project.protected_branches.create!(name: 'foo')
+ it 'returns false when default_branch_protection is in full protection and user is developer' do
+ project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_FULL)
- expect(project.protected_branch?('foo')).to eq(true)
+ expect(project.user_can_push_to_empty_repo?(user)).to be_falsey
end
- it 'returns true when the branch matches a protected branch via wildcard match' do
- project.protected_branches.create!(name: 'production/*')
+ it 'returns false when default_branch_protection only lets devs merge and user is dev' do
+ project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
- expect(project.protected_branch?('production/some-branch')).to eq(true)
+ expect(project.user_can_push_to_empty_repo?(user)).to be_falsey
end
- it 'returns false when the branch does not match a protected branch via direct match' do
- expect(project.protected_branch?('foo')).to eq(false)
+ it 'returns true when default_branch_protection lets devs push and user is developer' do
+ project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
+
+ expect(project.user_can_push_to_empty_repo?(user)).to be_truthy
+ end
+
+ it 'returns true when default_branch_protection is unprotected and user is developer' do
+ project.team << [user, :developer]
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
+
+ expect(project.user_can_push_to_empty_repo?(user)).to be_truthy
end
- it 'returns false when the branch does not match a protected branch via wildcard match' do
- project.protected_branches.create!(name: 'production/*')
+ it 'returns true when user is master' do
+ project.team << [user, :master]
- expect(project.protected_branch?('staging/some-branch')).to eq(false)
+ expect(project.user_can_push_to_empty_repo?(user)).to be_truthy
end
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 2a053b1804f..f7dbfd712cc 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -340,14 +340,14 @@ describe Repository, models: true do
describe '#add_branch' do
context 'when pre hooks were successful' do
- it 'should run without errors' do
+ it 'runs without errors' do
hook = double(trigger: [true, nil])
expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook)
expect { repository.add_branch(user, 'new_feature', 'master') }.not_to raise_error
end
- it 'should create the branch' do
+ it 'creates the branch' do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil])
branch = repository.add_branch(user, 'new_feature', 'master')
@@ -363,7 +363,7 @@ describe Repository, models: true do
end
context 'when pre hooks failed' do
- it 'should get an error' do
+ it 'gets an error' do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, ''])
expect do
@@ -371,7 +371,7 @@ describe Repository, models: true do
end.to raise_error(GitHooksService::PreReceiveError)
end
- it 'should not create the branch' do
+ it 'does not create the branch' do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, ''])
expect do
@@ -387,14 +387,14 @@ describe Repository, models: true do
let(:blank_sha) { '0000000000000000000000000000000000000000' }
context 'when pre hooks were successful' do
- it 'should run without errors' do
+ it 'runs without errors' do
expect_any_instance_of(GitHooksService).to receive(:execute).
with(user, project.repository.path_to_repo, old_rev, blank_sha, 'refs/heads/feature')
expect { repository.rm_branch(user, 'feature') }.not_to raise_error
end
- it 'should delete the branch' do
+ it 'deletes the branch' do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil])
expect { repository.rm_branch(user, 'feature') }.not_to raise_error
@@ -404,7 +404,7 @@ describe Repository, models: true do
end
context 'when pre hooks failed' do
- it 'should get an error' do
+ it 'gets an error' do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, ''])
expect do
@@ -412,7 +412,7 @@ describe Repository, models: true do
end.to raise_error(GitHooksService::PreReceiveError)
end
- it 'should not delete the branch' do
+ it 'does not delete the branch' do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, ''])
expect do
@@ -433,13 +433,13 @@ describe Repository, models: true do
and_yield.and_return(true)
end
- it 'should run without errors' do
+ it 'runs without errors' do
expect do
repository.commit_with_hooks(user, 'feature') { sample_commit.id }
end.not_to raise_error
end
- it 'should ensure the autocrlf Git option is set to :input' do
+ it 'ensures the autocrlf Git option is set to :input' do
expect(repository).to receive(:update_autocrlf_option)
repository.commit_with_hooks(user, 'feature') { sample_commit.id }
@@ -455,7 +455,7 @@ describe Repository, models: true do
end
context 'when pre hooks failed' do
- it 'should get an error' do
+ it 'gets an error' do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, ''])
expect do
@@ -715,7 +715,7 @@ describe Repository, models: true do
end
describe '#merge' do
- it 'should merge the code and return the commit id' do
+ it 'merges the code and return the commit id' do
expect(merge_commit).to be_present
expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present
end
@@ -726,13 +726,13 @@ describe Repository, models: true do
let(:update_image_commit) { repository.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
context 'when there is a conflict' do
- it 'should abort the operation' do
+ it 'aborts the operation' do
expect(repository.revert(user, new_image_commit, 'master')).to eq(false)
end
end
context 'when commit was already reverted' do
- it 'should abort the operation' do
+ it 'aborts the operation' do
repository.revert(user, update_image_commit, 'master')
expect(repository.revert(user, update_image_commit, 'master')).to eq(false)
@@ -740,13 +740,13 @@ describe Repository, models: true do
end
context 'when commit can be reverted' do
- it 'should revert the changes' do
+ it 'reverts the changes' do
expect(repository.revert(user, update_image_commit, 'master')).to be_truthy
end
end
context 'reverting a merge commit' do
- it 'should revert the changes' do
+ it 'reverts the changes' do
merge_commit
expect(repository.blob_at_branch('master', 'files/ruby/feature.rb')).to be_present
@@ -762,13 +762,13 @@ describe Repository, models: true do
let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') }
context 'when there is a conflict' do
- it 'should abort the operation' do
+ it 'aborts the operation' do
expect(repository.cherry_pick(user, conflict_commit, 'master')).to eq(false)
end
end
context 'when commit was already cherry-picked' do
- it 'should abort the operation' do
+ it 'aborts the operation' do
repository.cherry_pick(user, pickable_commit, 'master')
expect(repository.cherry_pick(user, pickable_commit, 'master')).to eq(false)
@@ -776,13 +776,13 @@ describe Repository, models: true do
end
context 'when commit can be cherry-picked' do
- it 'should cherry-pick the changes' do
+ it 'cherry-picks the changes' do
expect(repository.cherry_pick(user, pickable_commit, 'master')).to be_truthy
end
end
context 'cherry-picking a merge commit' do
- it 'should cherry-pick the changes' do
+ it 'cherry-picks the changes' do
expect(repository.blob_at_branch('master', 'foo/bar/.gitkeep')).to be_nil
repository.cherry_pick(user, pickable_merge, 'master')
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 67b3783d514..05056a4bb47 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -65,13 +65,13 @@ describe Service, models: true do
end
let(:project) { create(:project) }
- describe 'should be prefilled for projects pushover service' do
+ describe 'is prefilled for projects pushover service' do
before do
service_template
project.build_missing_services
end
- it "should have all fields prefilled" do
+ it "has all fields prefilled" do
service = project.pushover_service
expect(service.template).to eq(false)
expect(service.device).to eq('MyDevice')
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 9922cba21a8..bd86415050c 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -166,7 +166,7 @@ describe User, models: true do
allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(['*.example.com'])
end
- it 'should give priority to whitelist and allow info@test.example.com' do
+ it 'gives priority to whitelist and allow info@test.example.com' do
user = build(:user, email: 'info@test.example.com')
expect(user).to be_valid
end
@@ -304,18 +304,18 @@ describe User, models: true do
end
describe '#generate_password' do
- it "should execute callback when force_random_password specified" do
+ it "executes callback when force_random_password specified" do
user = build(:user, force_random_password: true)
expect(user).to receive(:generate_password)
user.save
end
- it "should not generate password by default" do
+ it "does not generate password by default" do
user = create(:user, password: 'abcdefghe')
expect(user.password).to eq('abcdefghe')
end
- it "should generate password when forcing random password" do
+ it "generates password when forcing random password" do
allow(Devise).to receive(:friendly_token).and_return('123456789')
user = create(:user, password: 'abcdefg', force_random_password: true)
expect(user.password).to eq('12345678')
@@ -323,7 +323,7 @@ describe User, models: true do
end
describe 'authentication token' do
- it "should have authentication token" do
+ it "has authentication token" do
user = create(:user)
expect(user.authentication_token).not_to be_blank
end
@@ -430,7 +430,7 @@ describe User, models: true do
describe 'blocking user' do
let(:user) { create(:user, name: 'John Smith') }
- it "should block user" do
+ it "blocks user" do
user.block
expect(user.blocked?).to be_truthy
end
@@ -501,7 +501,7 @@ describe User, models: true do
describe 'with defaults' do
let(:user) { User.new }
- it "should apply defaults to user" do
+ it "applies defaults to user" do
expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit)
expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group)
expect(user.theme_id).to eq(Gitlab.config.gitlab.default_theme)
@@ -512,7 +512,7 @@ describe User, models: true do
describe 'with default overrides' do
let(:user) { User.new(projects_limit: 123, can_create_group: false, can_create_team: true, theme_id: 1) }
- it "should apply defaults to user" do
+ it "applies defaults to user" do
expect(user.projects_limit).to eq(123)
expect(user.can_create_group).to be_falsey
expect(user.theme_id).to eq(1)
@@ -602,7 +602,7 @@ describe User, models: true do
describe 'by_username_or_id' do
let(:user1) { create(:user, username: 'foo') }
- it "should get the correct user" do
+ it "gets the correct user" do
expect(User.by_username_or_id(user1.id)).to eq(user1)
expect(User.by_username_or_id('foo')).to eq(user1)
expect(User.by_username_or_id(-1)).to be_nil
@@ -614,7 +614,7 @@ describe User, models: true do
let(:username) { 'John' }
let!(:user) { create(:user, username: username) }
- it 'should get the correct user' do
+ it 'gets the correct user' do
expect(User.by_login(user.email.upcase)).to eq user
expect(User.by_login(user.email)).to eq user
expect(User.by_login(username.downcase)).to eq user
@@ -639,7 +639,7 @@ describe User, models: true do
describe 'all_ssh_keys' do
it { is_expected.to have_many(:keys).dependent(:destroy) }
- it "should have all ssh keys" do
+ it "has all ssh keys" do
user = create :user
key = create :key, key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD33bWLBxu48Sev9Fert1yzEO4WGcWglWF7K/AwblIUFselOt/QdOL9DSjpQGxLagO1s9wl53STIO8qGS4Ms0EJZyIXOEFMjFJ5xmjSy+S37By4sG7SsltQEHMxtbtFOaW5LV2wCrX+rUsRNqLMamZjgjcPO0/EgGCXIGMAYW4O7cwGZdXWYIhQ1Vwy+CsVMDdPkPgBXqK7nR/ey8KMs8ho5fMNgB5hBw/AL9fNGhRw3QTD6Q12Nkhl4VZES2EsZqlpNnJttnPdp847DUsT6yuLRlfiQfz5Cn9ysHFdXObMN5VYIiPFwHeYCZp1X2S4fDZooRE8uOLTfxWHPXwrhqSH", user_id: user.id
@@ -650,12 +650,12 @@ describe User, models: true do
describe '#avatar_type' do
let(:user) { create(:user) }
- it "should be true if avatar is image" do
+ it "is true if avatar is image" do
user.update_attribute(:avatar, 'uploads/avatar.png')
expect(user.avatar_type).to be_truthy
end
- it "should be false if avatar is html page" do
+ it "is false if avatar is html page" do
user.update_attribute(:avatar, 'uploads/avatar.html')
expect(user.avatar_type).to eq(["only images allowed"])
end
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
index ddc49495eda..5c34b1b0a30 100644
--- a/spec/models/wiki_page_spec.rb
+++ b/spec/models/wiki_page_spec.rb
@@ -147,12 +147,12 @@ describe WikiPage, models: true do
@page = wiki.find_page("Delete Page")
end
- it "should delete the page" do
+ it "deletes the page" do
@page.delete
expect(wiki.pages).to be_empty
end
- it "should return true" do
+ it "returns true" do
expect(@page.delete).to eq(true)
end
end
@@ -183,7 +183,7 @@ describe WikiPage, models: true do
destroy_page("Title")
end
- it "should be replace a hyphen to a space" do
+ it "replaces a hyphen to a space" do
@page.title = "Import-existing-repositories-into-GitLab"
expect(@page.title).to eq("Import existing repositories into GitLab")
end
diff --git a/spec/requests/api/api_helpers_spec.rb b/spec/requests/api/api_helpers_spec.rb
index 831889afb6c..c65510fadec 100644
--- a/spec/requests/api/api_helpers_spec.rb
+++ b/spec/requests/api/api_helpers_spec.rb
@@ -41,19 +41,19 @@ describe API::Helpers, api: true do
describe ".current_user" do
describe "when authenticating using a user's private token" do
- it "should return nil for an invalid token" do
+ it "returns nil for an invalid token" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = 'invalid token'
allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false }
expect(current_user).to be_nil
end
- it "should return nil for a user without access" do
+ it "returns nil for a user without access" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = user.private_token
allow_any_instance_of(Gitlab::UserAccess).to receive(:allowed?).and_return(false)
expect(current_user).to be_nil
end
- it "should leave user as is when sudo not specified" do
+ it "leaves user as is when sudo not specified" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = user.private_token
expect(current_user).to eq(user)
clear_env
@@ -65,19 +65,19 @@ describe API::Helpers, api: true do
describe "when authenticating using a user's personal access tokens" do
let(:personal_access_token) { create(:personal_access_token, user: user) }
- it "should return nil for an invalid token" do
+ it "returns nil for an invalid token" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = 'invalid token'
allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false }
expect(current_user).to be_nil
end
- it "should return nil for a user without access" do
+ it "returns nil for a user without access" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = personal_access_token.token
allow_any_instance_of(Gitlab::UserAccess).to receive(:allowed?).and_return(false)
expect(current_user).to be_nil
end
- it "should leave user as is when sudo not specified" do
+ it "leaves user as is when sudo not specified" do
env[API::Helpers::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect(current_user).to eq(user)
clear_env
@@ -100,7 +100,7 @@ describe API::Helpers, api: true do
end
end
- it "should change current user to sudo when admin" do
+ it "changes current user to sudo when admin" do
set_env(admin, user.id)
expect(current_user).to eq(user)
set_param(admin, user.id)
@@ -111,7 +111,7 @@ describe API::Helpers, api: true do
expect(current_user).to eq(user)
end
- it "should throw an error when the current user is not an admin and attempting to sudo" do
+ it "throws an error when the current user is not an admin and attempting to sudo" do
set_env(user, admin.id)
expect { current_user }.to raise_error(Exception)
set_param(user, admin.id)
@@ -122,7 +122,7 @@ describe API::Helpers, api: true do
expect { current_user }.to raise_error(Exception)
end
- it "should throw an error when the user cannot be found for a given id" do
+ it "throws an error when the user cannot be found for a given id" do
id = user.id + admin.id
expect(user.id).not_to eq(id)
expect(admin.id).not_to eq(id)
@@ -133,7 +133,7 @@ describe API::Helpers, api: true do
expect { current_user }.to raise_error(Exception)
end
- it "should throw an error when the user cannot be found for a given username" do
+ it "throws an error when the user cannot be found for a given username" do
username = "#{user.username}#{admin.username}"
expect(user.username).not_to eq(username)
expect(admin.username).not_to eq(username)
@@ -144,7 +144,7 @@ describe API::Helpers, api: true do
expect { current_user }.to raise_error(Exception)
end
- it "should handle sudo's to oneself" do
+ it "handles sudo's to oneself" do
set_env(admin, admin.id)
expect(current_user).to eq(admin)
set_param(admin, admin.id)
@@ -155,7 +155,7 @@ describe API::Helpers, api: true do
expect(current_user).to eq(admin)
end
- it "should handle multiple sudo's to oneself" do
+ it "handles multiple sudo's to oneself" do
set_env(admin, user.id)
expect(current_user).to eq(user)
expect(current_user).to eq(user)
@@ -171,7 +171,7 @@ describe API::Helpers, api: true do
expect(current_user).to eq(user)
end
- it "should handle multiple sudo's to oneself using string ids" do
+ it "handles multiple sudo's to oneself using string ids" do
set_env(admin, user.id.to_s)
expect(current_user).to eq(user)
expect(current_user).to eq(user)
@@ -183,7 +183,7 @@ describe API::Helpers, api: true do
end
describe '.sudo_identifier' do
- it "should return integers when input is an int" do
+ it "returns integers when input is an int" do
set_env(admin, '123')
expect(sudo_identifier).to eq(123)
set_env(admin, '0001234567890')
@@ -195,7 +195,7 @@ describe API::Helpers, api: true do
expect(sudo_identifier).to eq(1234567890)
end
- it "should return string when input is an is not an int" do
+ it "returns string when input is an is not an int" do
set_env(admin, '12.30')
expect(sudo_identifier).to eq("12.30")
set_env(admin, 'hello')
diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb
index 2b74dd4bbb0..73c268c0d1e 100644
--- a/spec/requests/api/award_emoji_spec.rb
+++ b/spec/requests/api/award_emoji_spec.rb
@@ -22,7 +22,7 @@ describe API::API, api: true do
expect(json_response.first['name']).to eq(award_emoji.name)
end
- it "should return a 404 error when issue id not found" do
+ it "returns a 404 error when issue id not found" do
get api("/projects/#{project.id}/issues/12345/award_emoji", user)
expect(response).to have_http_status(404)
@@ -124,13 +124,13 @@ describe API::API, api: true do
expect(json_response['user']['username']).to eq(user.username)
end
- it "should return a 400 bad request error if the name is not given" do
+ it "returns a 400 bad request error if the name is not given" do
post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user)
expect(response).to have_http_status(400)
end
- it "should return a 401 unauthorized error if the user is not authenticated" do
+ it "returns a 401 unauthorized error if the user is not authenticated" do
post api("/projects/#{project.id}/issues/#{issue.id}/award_emoji"), name: 'thumbsup'
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb
index e8fd697965f..9444138f93d 100644
--- a/spec/requests/api/branches_spec.rb
+++ b/spec/requests/api/branches_spec.rb
@@ -13,7 +13,7 @@ describe API::API, api: true do
let!(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
describe "GET /projects/:id/repository/branches" do
- it "should return an array of project branches" do
+ it "returns an array of project branches" do
project.repository.expire_cache
get api("/projects/#{project.id}/repository/branches", user)
@@ -25,7 +25,7 @@ describe API::API, api: true do
end
describe "GET /projects/:id/repository/branches/:branch" do
- it "should return the branch information for a single branch" do
+ it "returns the branch information for a single branch" do
get api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_http_status(200)
@@ -36,12 +36,12 @@ describe API::API, api: true do
expect(json_response['developers_can_merge']).to eq(false)
end
- it "should return a 403 error if guest" do
+ it "returns a 403 error if guest" do
get api("/projects/#{project.id}/repository/branches", user2)
expect(response).to have_http_status(403)
end
- it "should return a 404 error if branch is not available" do
+ it "returns a 404 error if branch is not available" do
get api("/projects/#{project.id}/repository/branches/unknown", user)
expect(response).to have_http_status(404)
end
@@ -138,17 +138,17 @@ describe API::API, api: true do
end
end
- it "should return a 404 error if branch not found" do
+ it "returns a 404 error if branch not found" do
put api("/projects/#{project.id}/repository/branches/unknown/protect", user)
expect(response).to have_http_status(404)
end
- it "should return a 403 error if guest" do
+ it "returns a 403 error if guest" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user2)
expect(response).to have_http_status(403)
end
- it "should return success when protect branch again" do
+ it "returns success when protect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
expect(response).to have_http_status(200)
@@ -156,7 +156,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/repository/branches/:branch/unprotect" do
- it "should unprotect a single branch" do
+ it "unprotects a single branch" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
expect(response).to have_http_status(200)
@@ -165,12 +165,12 @@ describe API::API, api: true do
expect(json_response['protected']).to eq(false)
end
- it "should return success when unprotect branch" do
+ it "returns success when unprotect branch" do
put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user)
expect(response).to have_http_status(404)
end
- it "should return success when unprotect branch again" do
+ it "returns success when unprotect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
expect(response).to have_http_status(200)
@@ -178,7 +178,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/repository/branches" do
- it "should create a new branch" do
+ it "creates a new branch" do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'feature1',
ref: branch_sha
@@ -189,14 +189,14 @@ describe API::API, api: true do
expect(json_response['commit']['id']).to eq(branch_sha)
end
- it "should deny for user without push access" do
+ it "denies for user without push access" do
post api("/projects/#{project.id}/repository/branches", user2),
branch_name: branch_name,
ref: branch_sha
expect(response).to have_http_status(403)
end
- it 'should return 400 if branch name is invalid' do
+ it 'returns 400 if branch name is invalid' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new design',
ref: branch_sha
@@ -204,7 +204,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Branch name is invalid')
end
- it 'should return 400 if branch already exists' do
+ it 'returns 400 if branch already exists' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design1',
ref: branch_sha
@@ -217,7 +217,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Branch already exists')
end
- it 'should return 400 if ref name is invalid' do
+ it 'returns 400 if ref name is invalid' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design3',
ref: 'foo'
@@ -231,25 +231,25 @@ describe API::API, api: true do
allow_any_instance_of(Repository).to receive(:rm_branch).and_return(true)
end
- it "should remove branch" do
+ it "removes branch" do
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_http_status(200)
expect(json_response['branch_name']).to eq(branch_name)
end
- it 'should return 404 if branch not exists' do
+ it 'returns 404 if branch not exists' do
delete api("/projects/#{project.id}/repository/branches/foobar", user)
expect(response).to have_http_status(404)
end
- it "should remove protected branch" do
+ it "removes protected branch" do
project.protected_branches.create(name: branch_name)
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_http_status(405)
expect(json_response['message']).to eq('Protected branch cant be removed')
end
- it "should not remove HEAD branch" do
+ it "does not remove HEAD branch" do
delete api("/projects/#{project.id}/repository/branches/master", user)
expect(response).to have_http_status(405)
expect(json_response['message']).to eq('Cannot remove HEAD branch')
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index 86a7b242fbe..966d302dfd3 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -18,7 +18,7 @@ describe API::API, api: true do
before { get api("/projects/#{project.id}/builds?#{query}", api_user) }
context 'authorized user' do
- it 'should return project builds' do
+ it 'returns project builds' do
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
end
@@ -84,7 +84,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/commits/#{project.commit.id}/builds", api_user)
end
- it 'should return project builds for specific commit' do
+ it 'returns project builds for specific commit' do
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.size).to eq 2
@@ -113,7 +113,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/commits/#{project.commit.id}/builds", nil)
end
- it 'should not return project builds' do
+ it 'does not return project builds' do
expect(response).to have_http_status(401)
expect(json_response.except('message')).to be_empty
end
@@ -125,7 +125,7 @@ describe API::API, api: true do
before { get api("/projects/#{project.id}/builds/#{build.id}", api_user) }
context 'authorized user' do
- it 'should return specific build data' do
+ it 'returns specific build data' do
expect(response).to have_http_status(200)
expect(json_response['name']).to eq('test')
end
@@ -134,7 +134,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not return specific build data' do
+ it 'does not return specific build data' do
expect(response).to have_http_status(401)
end
end
@@ -152,7 +152,7 @@ describe API::API, api: true do
'Content-Disposition' => 'attachment; filename=ci_build_artifacts.zip' }
end
- it 'should return specific build artifacts' do
+ it 'returns specific build artifacts' do
expect(response).to have_http_status(200)
expect(response.headers).to include(download_headers)
end
@@ -161,13 +161,13 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not return specific build artifacts' do
+ it 'does not return specific build artifacts' do
expect(response).to have_http_status(401)
end
end
end
- it 'should not return build artifacts if not uploaded' do
+ it 'does not return build artifacts if not uploaded' do
expect(response).to have_http_status(404)
end
end
@@ -272,7 +272,7 @@ describe API::API, api: true do
end
context 'authorized user' do
- it 'should return specific build trace' do
+ it 'returns specific build trace' do
expect(response).to have_http_status(200)
expect(response.body).to eq(build.trace)
end
@@ -281,7 +281,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not return specific build trace' do
+ it 'does not return specific build trace' do
expect(response).to have_http_status(401)
end
end
@@ -292,7 +292,7 @@ describe API::API, api: true do
context 'authorized user' do
context 'user with :update_build persmission' do
- it 'should cancel running or pending build' do
+ it 'cancels running or pending build' do
expect(response).to have_http_status(201)
expect(project.builds.first.status).to eq('canceled')
end
@@ -301,7 +301,7 @@ describe API::API, api: true do
context 'user without :update_build permission' do
let(:api_user) { reporter.user }
- it 'should not cancel build' do
+ it 'does not cancel build' do
expect(response).to have_http_status(403)
end
end
@@ -310,7 +310,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not cancel build' do
+ it 'does not cancel build' do
expect(response).to have_http_status(401)
end
end
@@ -323,7 +323,7 @@ describe API::API, api: true do
context 'authorized user' do
context 'user with :update_build permission' do
- it 'should retry non-running build' do
+ it 'retries non-running build' do
expect(response).to have_http_status(201)
expect(project.builds.first.status).to eq('canceled')
expect(json_response['status']).to eq('pending')
@@ -333,7 +333,7 @@ describe API::API, api: true do
context 'user without :update_build permission' do
let(:api_user) { reporter.user }
- it 'should not retry build' do
+ it 'does not retry build' do
expect(response).to have_http_status(403)
end
end
@@ -342,7 +342,7 @@ describe API::API, api: true do
context 'unauthorized user' do
let(:api_user) { nil }
- it 'should not retry build' do
+ it 'does not retry build' do
expect(response).to have_http_status(401)
end
end
@@ -356,14 +356,14 @@ describe API::API, api: true do
context 'build is erasable' do
let(:build) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) }
- it 'should erase build content' do
+ it 'erases build content' do
expect(response.status).to eq 201
expect(build.trace).to be_empty
expect(build.artifacts_file.exists?).to be_falsy
expect(build.artifacts_metadata.exists?).to be_falsy
end
- it 'should update build' do
+ it 'updates build' do
expect(build.reload.erased_at).to be_truthy
expect(build.reload.erased_by).to eq user
end
@@ -372,7 +372,7 @@ describe API::API, api: true do
context 'build is not erasable' do
let(:build) { create(:ci_build, :trace, project: project, pipeline: pipeline) }
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response.status).to eq 403
end
end
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 2da01da7fa1..2d6093fec7a 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -99,7 +99,7 @@ describe API::CommitStatuses, api: true do
context "guest user" do
before { get api(get_url, guest) }
- it "should not return project commits" do
+ it "does not return project commits" do
expect(response).to have_http_status(403)
end
end
@@ -107,7 +107,7 @@ describe API::CommitStatuses, api: true do
context "unauthorized user" do
before { get api(get_url) }
- it "should not return project commits" do
+ it "does not return project commits" do
expect(response).to have_http_status(401)
end
end
@@ -179,7 +179,7 @@ describe API::CommitStatuses, api: true do
context 'reporter user' do
before { post api(post_url, reporter) }
- it 'should not create commit status' do
+ it 'does not create commit status' do
expect(response).to have_http_status(403)
end
end
@@ -187,7 +187,7 @@ describe API::CommitStatuses, api: true do
context 'guest user' do
before { post api(post_url, guest) }
- it 'should not create commit status' do
+ it 'does not create commit status' do
expect(response).to have_http_status(403)
end
end
@@ -195,7 +195,7 @@ describe API::CommitStatuses, api: true do
context 'unauthorized user' do
before { post api(post_url) }
- it 'should not create commit status' do
+ it 'does not create commit status' do
expect(response).to have_http_status(401)
end
end
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 6085b21116c..8cd25b20650 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -17,7 +17,7 @@ describe API::API, api: true do
context "authorized user" do
before { project.team << [user2, :reporter] }
- it "should return project commits" do
+ it "returns project commits" do
get api("/projects/#{project.id}/repository/commits", user)
expect(response).to have_http_status(200)
@@ -27,14 +27,14 @@ describe API::API, api: true do
end
context "unauthorized user" do
- it "should not return project commits" do
+ it "does not return project commits" do
get api("/projects/#{project.id}/repository/commits")
expect(response).to have_http_status(401)
end
end
context "since optional parameter" do
- it "should return project commits since provided parameter" do
+ it "returns project commits since provided parameter" do
commits = project.repository.commits("master")
since = commits.second.created_at
@@ -47,7 +47,7 @@ describe API::API, api: true do
end
context "until optional parameter" do
- it "should return project commits until provided parameter" do
+ it "returns project commits until provided parameter" do
commits = project.repository.commits("master")
before = commits.second.created_at
@@ -60,7 +60,7 @@ describe API::API, api: true do
end
context "invalid xmlschema date parameters" do
- it "should return an invalid parameter error message" do
+ it "returns an invalid parameter error message" do
get api("/projects/#{project.id}/repository/commits?since=invalid-date", user)
expect(response).to have_http_status(400)
@@ -71,7 +71,7 @@ describe API::API, api: true do
describe "GET /projects:id/repository/commits/:sha" do
context "authorized user" do
- it "return a commit by sha" do
+ it "returns a commit by sha" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response).to have_http_status(200)
@@ -82,7 +82,7 @@ describe API::API, api: true do
expect(json_response['stats']['total']).to eq(project.repository.commit.stats.total)
end
- it "return a 404 error if not found" do
+ it "returns a 404 error if not found" do
get api("/projects/#{project.id}/repository/commits/invalid_sha", user)
expect(response).to have_http_status(404)
end
@@ -93,7 +93,7 @@ describe API::API, api: true do
expect(json_response['status']).to be_nil
end
- it "returns status for CI when pipeline succeeded" do
+ it "returns status for CI" do
pipeline = project.ensure_pipeline(project.repository.commit.sha, 'master')
pipeline.update(status: 'success')
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
@@ -110,7 +110,7 @@ describe API::API, api: true do
end
context "unauthorized user" do
- it "should not return the selected commit" do
+ it "does not return the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}")
expect(response).to have_http_status(401)
end
@@ -121,7 +121,7 @@ describe API::API, api: true do
context "authorized user" do
before { project.team << [user2, :reporter] }
- it "should return the diff of the selected commit" do
+ it "returns the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user)
expect(response).to have_http_status(200)
@@ -130,14 +130,14 @@ describe API::API, api: true do
expect(json_response.first.keys).to include "diff"
end
- it "should return a 404 error if invalid commit" do
+ it "returns a 404 error if invalid commit" do
get api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user)
expect(response).to have_http_status(404)
end
end
context "unauthorized user" do
- it "should not return the diff of the selected commit" do
+ it "does not return the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff")
expect(response).to have_http_status(401)
end
@@ -146,7 +146,7 @@ describe API::API, api: true do
describe 'GET /projects:id/repository/commits/:sha/comments' do
context 'authorized user' do
- it 'should return merge_request comments' do
+ it 'returns merge_request comments' do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -155,14 +155,14 @@ describe API::API, api: true do
expect(json_response.first['author']['id']).to eq(user.id)
end
- it 'should return a 404 error if merge_request_id not found' do
+ it 'returns a 404 error if merge_request_id not found' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments", user)
expect(response).to have_http_status(404)
end
end
context 'unauthorized user' do
- it 'should not return the diff of the selected commit' do
+ it 'does not return the diff of the selected commit' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments")
expect(response).to have_http_status(401)
end
@@ -171,7 +171,7 @@ describe API::API, api: true do
describe 'POST /projects:id/repository/commits/:sha/comments' do
context 'authorized user' do
- it 'should return comment' do
+ it 'returns comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment'
expect(response).to have_http_status(201)
expect(json_response['note']).to eq('My comment')
@@ -180,7 +180,7 @@ describe API::API, api: true do
expect(json_response['line_type']).to be_nil
end
- it 'should return the inline comment' do
+ it 'returns the inline comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 7, line_type: 'new'
expect(response).to have_http_status(201)
expect(json_response['note']).to eq('My comment')
@@ -189,19 +189,19 @@ describe API::API, api: true do
expect(json_response['line_type']).to eq('new')
end
- it 'should return 400 if note is missing' do
+ it 'returns 400 if note is missing' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
expect(response).to have_http_status(400)
end
- it 'should return 404 if note is attached to non existent commit' do
+ it 'returns 404 if note is attached to non existent commit' do
post api("/projects/#{project.id}/repository/commits/1234ab/comments", user), note: 'My comment'
expect(response).to have_http_status(404)
end
end
context 'unauthorized user' do
- it 'should not return the diff of the selected commit' do
+ it 'does not return the diff of the selected commit' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments")
expect(response).to have_http_status(401)
end
diff --git a/spec/requests/api/deploy_keys.rb b/spec/requests/api/deploy_keys.rb
deleted file mode 100644
index ac42288bc34..00000000000
--- a/spec/requests/api/deploy_keys.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require 'spec_helper'
-
-describe API::API, api: true do
- include ApiHelpers
-
- let(:user) { create(:user) }
- let(:project) { create(:project, creator_id: user.id) }
- let!(:deploy_keys_project) { create(:deploy_keys_project, project: project) }
- let(:admin) { create(:admin) }
-
- describe 'GET /deploy_keys' do
- before { admin }
-
- context 'when unauthenticated' do
- it 'should return authentication error' do
- get api('/deploy_keys')
- expect(response.status).to eq(401)
- end
- end
-
- context 'when authenticated as non-admin user' do
- it 'should return a 403 error' do
- get api('/deploy_keys', user)
- expect(response.status).to eq(403)
- end
- end
-
- context 'when authenticated as admin' do
- it 'should return all deploy keys' do
- get api('/deploy_keys', admin)
- expect(response.status).to eq(200)
-
- expect(json_response).to be_an Array
- expect(json_response.first['id']).to eq(deploy_keys_project.deploy_key.id)
- end
- end
- end
-end
diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb
new file mode 100644
index 00000000000..7d8cc45327c
--- /dev/null
+++ b/spec/requests/api/deploy_keys_spec.rb
@@ -0,0 +1,160 @@
+require 'spec_helper'
+
+describe API::API, api: true do
+ include ApiHelpers
+
+ let(:user) { create(:user) }
+ let(:admin) { create(:admin) }
+ let(:project) { create(:project, creator_id: user.id) }
+ let(:deploy_key) { create(:deploy_key, public: true) }
+
+ let!(:deploy_keys_project) do
+ create(:deploy_keys_project, project: project, deploy_key: deploy_key)
+ end
+
+ describe 'GET /deploy_keys' do
+ context 'when unauthenticated' do
+ it 'should return authentication error' do
+ get api('/deploy_keys')
+
+ expect(response.status).to eq(401)
+ end
+ end
+
+ context 'when authenticated as non-admin user' do
+ it 'should return a 403 error' do
+ get api('/deploy_keys', user)
+
+ expect(response.status).to eq(403)
+ end
+ end
+
+ context 'when authenticated as admin' do
+ it 'should return all deploy keys' do
+ get api('/deploy_keys', admin)
+
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['id']).to eq(deploy_keys_project.deploy_key.id)
+ end
+ end
+ end
+
+ describe 'GET /projects/:id/deploy_keys' do
+ before { deploy_key }
+
+ it 'should return array of ssh keys' do
+ get api("/projects/#{project.id}/deploy_keys", admin)
+
+ expect(response).to have_http_status(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['title']).to eq(deploy_key.title)
+ end
+ end
+
+ describe 'GET /projects/:id/deploy_keys/:key_id' do
+ it 'should return a single key' do
+ get api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
+
+ expect(response).to have_http_status(200)
+ expect(json_response['title']).to eq(deploy_key.title)
+ end
+
+ it 'should return 404 Not Found with invalid ID' do
+ get api("/projects/#{project.id}/deploy_keys/404", admin)
+
+ expect(response).to have_http_status(404)
+ end
+ end
+
+ describe 'POST /projects/:id/deploy_keys' do
+ it 'should not create an invalid ssh key' do
+ post api("/projects/#{project.id}/deploy_keys", admin), { title: 'invalid key' }
+
+ expect(response).to have_http_status(400)
+ expect(json_response['message']['key']).to eq([
+ 'can\'t be blank',
+ 'is too short (minimum is 0 characters)',
+ 'is invalid'
+ ])
+ end
+
+ it 'should not create a key without title' do
+ post api("/projects/#{project.id}/deploy_keys", admin), key: 'some key'
+
+ expect(response).to have_http_status(400)
+ expect(json_response['message']['title']).to eq([
+ 'can\'t be blank',
+ 'is too short (minimum is 0 characters)'
+ ])
+ end
+
+ it 'should create new ssh key' do
+ key_attrs = attributes_for :another_key
+
+ expect do
+ post api("/projects/#{project.id}/deploy_keys", admin), key_attrs
+ end.to change{ project.deploy_keys.count }.by(1)
+ end
+ end
+
+ describe 'DELETE /projects/:id/deploy_keys/:key_id' do
+ before { deploy_key }
+
+ it 'should delete existing key' do
+ expect do
+ delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
+ end.to change{ project.deploy_keys.count }.by(-1)
+ end
+
+ it 'should return 404 Not Found with invalid ID' do
+ delete api("/projects/#{project.id}/deploy_keys/404", admin)
+
+ expect(response).to have_http_status(404)
+ end
+ end
+
+ describe 'POST /projects/:id/deploy_keys/:key_id/enable' do
+ let(:project2) { create(:empty_project) }
+
+ context 'when the user can admin the project' do
+ it 'enables the key' do
+ expect do
+ post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", admin)
+ end.to change { project2.deploy_keys.count }.from(0).to(1)
+
+ expect(response).to have_http_status(201)
+ expect(json_response['id']).to eq(deploy_key.id)
+ end
+ end
+
+ context 'when authenticated as non-admin user' do
+ it 'should return a 404 error' do
+ post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", user)
+
+ expect(response).to have_http_status(404)
+ end
+ end
+ end
+
+ describe 'DELETE /projects/:id/deploy_keys/:key_id/disable' do
+ context 'when the user can admin the project' do
+ it 'disables the key' do
+ expect do
+ delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}/disable", admin)
+ end.to change { project.deploy_keys.count }.from(1).to(0)
+
+ expect(response).to have_http_status(200)
+ expect(json_response['id']).to eq(deploy_key.id)
+ end
+ end
+
+ context 'when authenticated as non-admin user' do
+ it 'should return a 404 error' do
+ delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}/disable", user)
+
+ expect(response).to have_http_status(404)
+ end
+ end
+ end
+end
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb
index 2e5448143d5..2d1213df8a7 100644
--- a/spec/requests/api/files_spec.rb
+++ b/spec/requests/api/files_spec.rb
@@ -9,7 +9,7 @@ describe API::API, api: true do
before { project.team << [user, :developer] }
describe "GET /projects/:id/repository/files" do
- it "should return file info" do
+ it "returns file info" do
params = {
file_path: file_path,
ref: 'master',
@@ -23,12 +23,12 @@ describe API::API, api: true do
expect(Base64.decode64(json_response['content']).lines.first).to eq("require 'fileutils'\n")
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
get api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
- it "should return a 404 if such file does not exist" do
+ it "returns a 404 if such file does not exist" do
params = {
file_path: 'app/models/application.rb',
ref: 'master',
@@ -49,18 +49,18 @@ describe API::API, api: true do
}
end
- it "should create a new file in project repo" do
+ it "creates a new file in project repo" do
post api("/projects/#{project.id}/repository/files", user), valid_params
expect(response).to have_http_status(201)
expect(json_response['file_path']).to eq('newfile.rb')
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
post api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
- it "should return a 400 if editor fails to create file" do
+ it "returns a 400 if editor fails to create file" do
allow_any_instance_of(Repository).to receive(:commit_file).
and_return(false)
@@ -79,13 +79,13 @@ describe API::API, api: true do
}
end
- it "should update existing file in project repo" do
+ it "updates existing file in project repo" do
put api("/projects/#{project.id}/repository/files", user), valid_params
expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path)
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
put api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
@@ -100,18 +100,18 @@ describe API::API, api: true do
}
end
- it "should delete existing file in project repo" do
+ it "deletes existing file in project repo" do
delete api("/projects/#{project.id}/repository/files", user), valid_params
expect(response).to have_http_status(200)
expect(json_response['file_path']).to eq(file_path)
end
- it "should return a 400 bad request if no params given" do
+ it "returns a 400 bad request if no params given" do
delete api("/projects/#{project.id}/repository/files", user)
expect(response).to have_http_status(400)
end
- it "should return a 400 if fails to create file" do
+ it "returns a 400 if fails to create file" do
allow_any_instance_of(Repository).to receive(:remove_file).and_return(false)
delete api("/projects/#{project.id}/repository/files", user), valid_params
diff --git a/spec/requests/api/fork_spec.rb b/spec/requests/api/fork_spec.rb
index a9f5aa924b7..f802fcd2d2e 100644
--- a/spec/requests/api/fork_spec.rb
+++ b/spec/requests/api/fork_spec.rb
@@ -20,7 +20,7 @@ describe API::API, api: true do
before { user3 }
context 'when authenticated' do
- it 'should fork if user has sufficient access to project' do
+ it 'forks if user has sufficient access to project' do
post api("/projects/fork/#{project.id}", user2)
expect(response).to have_http_status(201)
expect(json_response['name']).to eq(project.name)
@@ -30,7 +30,7 @@ describe API::API, api: true do
expect(json_response['forked_from_project']['id']).to eq(project.id)
end
- it 'should fork if user is admin' do
+ it 'forks if user is admin' do
post api("/projects/fork/#{project.id}", admin)
expect(response).to have_http_status(201)
expect(json_response['name']).to eq(project.name)
@@ -40,20 +40,20 @@ describe API::API, api: true do
expect(json_response['forked_from_project']['id']).to eq(project.id)
end
- it 'should fail on missing project access for the project to fork' do
+ it 'fails on missing project access for the project to fork' do
post api("/projects/fork/#{project.id}", user3)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
end
- it 'should fail if forked project exists in the user namespace' do
+ it 'fails if forked project exists in the user namespace' do
post api("/projects/fork/#{project.id}", user)
expect(response).to have_http_status(409)
expect(json_response['message']['name']).to eq(['has already been taken'])
expect(json_response['message']['path']).to eq(['has already been taken'])
end
- it 'should fail if project to fork from does not exist' do
+ it 'fails if project to fork from does not exist' do
post api('/projects/fork/424242', user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
@@ -61,7 +61,7 @@ describe API::API, api: true do
end
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
post api("/projects/fork/#{project.id}")
expect(response).to have_http_status(401)
expect(json_response['message']).to eq('401 Unauthorized')
diff --git a/spec/requests/api/group_members_spec.rb b/spec/requests/api/group_members_spec.rb
index 52f9e7d4681..8bd6a8062ae 100644
--- a/spec/requests/api/group_members_spec.rb
+++ b/spec/requests/api/group_members_spec.rb
@@ -28,7 +28,7 @@ describe API::API, api: true do
describe "GET /groups/:id/members" do
context "when authenticated as user that is part or the group" do
- it "each user: should return an array of members groups of group3" do
+ it "each user: returns an array of members groups of group3" do
[owner, master, developer, reporter, guest].each do |user|
get api("/groups/#{group_with_members.id}/members", user)
expect(response).to have_http_status(200)
@@ -52,14 +52,14 @@ describe API::API, api: true do
describe "POST /groups/:id/members" do
context "when not a member of the group" do
- it "should not add guest as member of group_no_members when adding being done by person outside the group" do
+ it "does not add guest as member of group_no_members when adding being done by person outside the group" do
post api("/groups/#{group_no_members.id}/members", reporter), user_id: guest.id, access_level: GroupMember::MASTER
expect(response).to have_http_status(403)
end
end
context "when a member of the group" do
- it "should return ok and add new member" do
+ it "returns ok and add new member" do
new_user = create(:user)
expect do
@@ -71,7 +71,7 @@ describe API::API, api: true do
expect(json_response['access_level']).to eq(GroupMember::MASTER)
end
- it "should not allow guest to modify group members" do
+ it "does not allow guest to modify group members" do
new_user = create(:user)
expect do
@@ -81,22 +81,22 @@ describe API::API, api: true do
expect(response).to have_http_status(403)
end
- it "should return error if member already exists" do
+ it "returns error if member already exists" do
post api("/groups/#{group_with_members.id}/members", owner), user_id: master.id, access_level: GroupMember::MASTER
expect(response).to have_http_status(409)
end
- it "should return a 400 error when user id is not given" do
+ it "returns a 400 error when user id is not given" do
post api("/groups/#{group_no_members.id}/members", owner), access_level: GroupMember::MASTER
expect(response).to have_http_status(400)
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id
expect(response).to have_http_status(400)
end
- it "should return a 422 error when access level is not known" do
+ it "returns a 422 error when access level is not known" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id, access_level: 1234
expect(response).to have_http_status(422)
end
@@ -105,7 +105,7 @@ describe API::API, api: true do
describe 'PUT /groups/:id/members/:user_id' do
context 'when not a member of the group' do
- it 'should return a 409 error if the user is not a group member' do
+ it 'returns a 409 error if the user is not a group member' do
put(
api("/groups/#{group_no_members.id}/members/#{developer.id}",
owner), access_level: GroupMember::MASTER
@@ -115,7 +115,7 @@ describe API::API, api: true do
end
context 'when a member of the group' do
- it 'should return ok and update member access level' do
+ it 'returns ok and update member access level' do
put(
api("/groups/#{group_with_members.id}/members/#{reporter.id}",
owner),
@@ -132,7 +132,7 @@ describe API::API, api: true do
expect(json_reporter['access_level']).to eq(GroupMember::MASTER)
end
- it 'should not allow guest to modify group members' do
+ it 'does not allow guest to modify group members' do
put(
api("/groups/#{group_with_members.id}/members/#{developer.id}",
guest),
@@ -149,14 +149,14 @@ describe API::API, api: true do
expect(json_developer['access_level']).to eq(GroupMember::DEVELOPER)
end
- it 'should return a 400 error when access level is not given' do
+ it 'returns a 400 error when access level is not given' do
put(
api("/groups/#{group_with_members.id}/members/#{master.id}", owner)
)
expect(response).to have_http_status(400)
end
- it 'should return a 422 error when access level is not known' do
+ it 'returns a 422 error when access level is not known' do
put(
api("/groups/#{group_with_members.id}/members/#{master.id}", owner),
access_level: 1234
@@ -168,7 +168,7 @@ describe API::API, api: true do
describe 'DELETE /groups/:id/members/:user_id' do
context 'when not a member of the group' do
- it "should not delete guest's membership of group_with_members" do
+ it "does not delete guest's membership of group_with_members" do
random_user = create(:user)
delete api("/groups/#{group_with_members.id}/members/#{owner.id}", random_user)
@@ -177,7 +177,7 @@ describe API::API, api: true do
end
context "when a member of the group" do
- it "should delete guest's membership of group" do
+ it "deletes guest's membership of group" do
expect do
delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner)
end.to change { group_with_members.members.count }.by(-1)
@@ -185,12 +185,12 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return a 404 error when user id is not known" do
+ it "returns a 404 error when user id is not known" do
delete api("/groups/#{group_with_members.id}/members/1328", owner)
expect(response).to have_http_status(404)
end
- it "should not allow guest to modify group members" do
+ it "does not allow guest to modify group members" do
delete api("/groups/#{group_with_members.id}/members/#{master.id}", guest)
expect(response).to have_http_status(403)
end
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index c2c94040ece..4860b23c2ed 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -21,14 +21,14 @@ describe API::API, api: true do
describe "GET /groups" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/groups")
expect(response).to have_http_status(401)
end
end
context "when authenticated as user" do
- it "normal user: should return an array of groups of user1" do
+ it "normal user: returns an array of groups of user1" do
get api("/groups", user1)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -38,7 +38,7 @@ describe API::API, api: true do
end
context "when authenticated as admin" do
- it "admin: should return an array of all groups" do
+ it "admin: returns an array of all groups" do
get api("/groups", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -70,12 +70,12 @@ describe API::API, api: true do
expect(json_response['shared_projects'][0]['id']).to eq(project.id)
end
- it "should not return a non existing group" do
+ it "does not return a non existing group" do
get api("/groups/1328", user1)
expect(response).to have_http_status(404)
end
- it "should not return a group not attached to user1" do
+ it "does not return a group not attached to user1" do
get api("/groups/#{group2.id}", user1)
expect(response).to have_http_status(404)
@@ -83,31 +83,31 @@ describe API::API, api: true do
end
context "when authenticated as admin" do
- it "should return any existing group" do
+ it "returns any existing group" do
get api("/groups/#{group2.id}", admin)
expect(response).to have_http_status(200)
expect(json_response['name']).to eq(group2.name)
end
- it "should not return a non existing group" do
+ it "does not return a non existing group" do
get api("/groups/1328", admin)
expect(response).to have_http_status(404)
end
end
context 'when using group path in URL' do
- it 'should return any existing group' do
+ it 'returns any existing group' do
get api("/groups/#{group1.path}", admin)
expect(response).to have_http_status(200)
expect(json_response['name']).to eq(group1.name)
end
- it 'should not return a non existing group' do
+ it 'does not return a non existing group' do
get api('/groups/unknown', admin)
expect(response).to have_http_status(404)
end
- it 'should not return a group not attached to user1' do
+ it 'does not return a group not attached to user1' do
get api("/groups/#{group2.path}", user1)
expect(response).to have_http_status(404)
@@ -161,7 +161,7 @@ describe API::API, api: true do
describe "GET /groups/:id/projects" do
context "when authenticated as user" do
- it "should return the group's projects" do
+ it "returns the group's projects" do
get api("/groups/#{group1.id}/projects", user1)
expect(response).to have_http_status(200)
@@ -170,12 +170,12 @@ describe API::API, api: true do
expect(project_names).to match_array([project1.name, project3.name])
end
- it "should not return a non existing group" do
+ it "does not return a non existing group" do
get api("/groups/1328/projects", user1)
expect(response).to have_http_status(404)
end
- it "should not return a group not attached to user1" do
+ it "does not return a group not attached to user1" do
get api("/groups/#{group2.id}/projects", user1)
expect(response).to have_http_status(404)
@@ -215,12 +215,12 @@ describe API::API, api: true do
expect(project_names).to match_array([project1.name, project3.name])
end
- it 'should not return a non existing group' do
+ it 'does not return a non existing group' do
get api('/groups/unknown/projects', admin)
expect(response).to have_http_status(404)
end
- it 'should not return a group not attached to user1' do
+ it 'does not return a group not attached to user1' do
get api("/groups/#{group2.path}/projects", user1)
expect(response).to have_http_status(404)
@@ -230,30 +230,30 @@ describe API::API, api: true do
describe "POST /groups" do
context "when authenticated as user without group permissions" do
- it "should not create group" do
+ it "does not create group" do
post api("/groups", user1), attributes_for(:group)
expect(response).to have_http_status(403)
end
end
context "when authenticated as user with group permissions" do
- it "should create group" do
+ it "creates group" do
post api("/groups", user3), attributes_for(:group)
expect(response).to have_http_status(201)
end
- it "should not create group, duplicate" do
+ it "does not create group, duplicate" do
post api("/groups", user3), { name: 'Duplicate Test', path: group2.path }
expect(response).to have_http_status(400)
expect(response.message).to eq("Bad Request")
end
- it "should return 400 bad request error if name not given" do
+ it "returns 400 bad request error if name not given" do
post api("/groups", user3), { path: group2.path }
expect(response).to have_http_status(400)
end
- it "should return 400 bad request error if path not given" do
+ it "returns 400 bad request error if path not given" do
post api("/groups", user3), { name: 'test' }
expect(response).to have_http_status(400)
end
@@ -262,24 +262,24 @@ describe API::API, api: true do
describe "DELETE /groups/:id" do
context "when authenticated as user" do
- it "should remove group" do
+ it "removes group" do
delete api("/groups/#{group1.id}", user1)
expect(response).to have_http_status(200)
end
- it "should not remove a group if not an owner" do
+ it "does not remove a group if not an owner" do
user4 = create(:user)
group1.add_master(user4)
delete api("/groups/#{group1.id}", user3)
expect(response).to have_http_status(403)
end
- it "should not remove a non existing group" do
+ it "does not remove a non existing group" do
delete api("/groups/1328", user1)
expect(response).to have_http_status(404)
end
- it "should not remove a group not attached to user1" do
+ it "does not remove a group not attached to user1" do
delete api("/groups/#{group2.id}", user1)
expect(response).to have_http_status(404)
@@ -287,12 +287,12 @@ describe API::API, api: true do
end
context "when authenticated as admin" do
- it "should remove any existing group" do
+ it "removes any existing group" do
delete api("/groups/#{group2.id}", admin)
expect(response).to have_http_status(200)
end
- it "should not remove a non existing group" do
+ it "does not remove a non existing group" do
delete api("/groups/1328", admin)
expect(response).to have_http_status(404)
end
@@ -308,14 +308,14 @@ describe API::API, api: true do
end
context "when authenticated as user" do
- it "should not transfer project to group" do
+ it "does not transfer project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", user2)
expect(response).to have_http_status(403)
end
end
context "when authenticated as admin" do
- it "should transfer project to group" do
+ it "transfers project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", admin)
expect(response).to have_http_status(201)
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 9d3d28e0b91..3cd4e981fb2 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -49,28 +49,28 @@ describe API::API, api: true do
describe "GET /issues" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/issues")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return an array of issues" do
+ it "returns an array of issues" do
get api("/issues", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(issue.title)
end
- it "should add pagination headers and keep query params" do
+ it "adds pagination headers and keep query params" do
get api("/issues?state=closed&per_page=3", user)
expect(response.headers['Link']).to eq(
'<http://www.example.com/api/v3/issues?page=1&per_page=3&private_token=%s&state=closed>; rel="first", <http://www.example.com/api/v3/issues?page=1&per_page=3&private_token=%s&state=closed>; rel="last"' % [user.private_token, user.private_token]
)
end
- it 'should return an array of closed issues' do
+ it 'returns an array of closed issues' do
get api('/issues?state=closed', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -78,7 +78,7 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq(closed_issue.id)
end
- it 'should return an array of opened issues' do
+ it 'returns an array of opened issues' do
get api('/issues?state=opened', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -86,7 +86,7 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq(issue.id)
end
- it 'should return an array of all issues' do
+ it 'returns an array of all issues' do
get api('/issues?state=all', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -95,7 +95,7 @@ describe API::API, api: true do
expect(json_response.second['id']).to eq(closed_issue.id)
end
- it 'should return an array of labeled issues' do
+ it 'returns an array of labeled issues' do
get api("/issues?labels=#{label.title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -103,7 +103,7 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an array of labeled issues when at least one label matches' do
+ it 'returns an array of labeled issues when at least one label matches' do
get api("/issues?labels=#{label.title},foo,bar", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -111,14 +111,14 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an empty array if no issue matches labels' do
+ it 'returns an empty array if no issue matches labels' do
get api('/issues?labels=foo,bar', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an array of labeled issues matching given state' do
+ it 'returns an array of labeled issues matching given state' do
get api("/issues?labels=#{label.title}&state=opened", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -127,7 +127,7 @@ describe API::API, api: true do
expect(json_response.first['state']).to eq('opened')
end
- it 'should return an empty array if no issue matches labels and state filters' do
+ it 'returns an empty array if no issue matches labels and state filters' do
get api("/issues?labels=#{label.title}&state=closed", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -282,7 +282,7 @@ describe API::API, api: true do
let(:base_url) { "/projects/#{project.id}" }
let(:title) { milestone.title }
- it 'should return project issues without confidential issues for non project members' do
+ it 'returns project issues without confidential issues for non project members' do
get api("#{base_url}/issues", non_member)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -290,7 +290,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project issues without confidential issues for project members with guest role' do
+ it 'returns project issues without confidential issues for project members with guest role' do
get api("#{base_url}/issues", guest)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -298,7 +298,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project confidential issues for author' do
+ it 'returns project confidential issues for author' do
get api("#{base_url}/issues", author)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -306,7 +306,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project confidential issues for assignee' do
+ it 'returns project confidential issues for assignee' do
get api("#{base_url}/issues", assignee)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -314,7 +314,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project issues with confidential issues for project members' do
+ it 'returns project issues with confidential issues for project members' do
get api("#{base_url}/issues", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -322,7 +322,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return project confidential issues for admin' do
+ it 'returns project confidential issues for admin' do
get api("#{base_url}/issues", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -330,7 +330,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(issue.title)
end
- it 'should return an array of labeled project issues' do
+ it 'returns an array of labeled project issues' do
get api("#{base_url}/issues?labels=#{label.title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -338,7 +338,7 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an array of labeled project issues when at least one label matches' do
+ it 'returns an array of labeled project issues when at least one label matches' do
get api("#{base_url}/issues?labels=#{label.title},foo,bar", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -346,28 +346,28 @@ describe API::API, api: true do
expect(json_response.first['labels']).to eq([label.title])
end
- it 'should return an empty array if no project issue matches labels' do
+ it 'returns an empty array if no project issue matches labels' do
get api("#{base_url}/issues?labels=foo,bar", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an empty array if no issue matches milestone' do
+ it 'returns an empty array if no issue matches milestone' do
get api("#{base_url}/issues?milestone=#{empty_milestone.title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an empty array if milestone does not exist' do
+ it 'returns an empty array if milestone does not exist' do
get api("#{base_url}/issues?milestone=foo", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'should return an array of issues in given milestone' do
+ it 'returns an array of issues in given milestone' do
get api("#{base_url}/issues?milestone=#{title}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -376,7 +376,7 @@ describe API::API, api: true do
expect(json_response.second['id']).to eq(closed_issue.id)
end
- it 'should return an array of issues matching state in milestone' do
+ it 'returns an array of issues matching state in milestone' do
get api("#{base_url}/issues?milestone=#{milestone.title}"\
'&state=closed', user)
expect(response).to have_http_status(200)
@@ -405,7 +405,7 @@ describe API::API, api: true do
expect(json_response['author']).to be_a Hash
end
- it "should return a project issue by id" do
+ it "returns a project issue by id" do
get api("/projects/#{project.id}/issues/#{issue.id}", user)
expect(response).to have_http_status(200)
@@ -413,7 +413,7 @@ describe API::API, api: true do
expect(json_response['iid']).to eq(issue.iid)
end
- it 'should return a project issue by iid' do
+ it 'returns a project issue by iid' do
get api("/projects/#{project.id}/issues?iid=#{issue.iid}", user)
expect(response.status).to eq 200
expect(json_response.first['title']).to eq issue.title
@@ -421,44 +421,44 @@ describe API::API, api: true do
expect(json_response.first['iid']).to eq issue.iid
end
- it "should return 404 if issue id not found" do
+ it "returns 404 if issue id not found" do
get api("/projects/#{project.id}/issues/54321", user)
expect(response).to have_http_status(404)
end
context 'confidential issues' do
- it "should return 404 for non project members" do
+ it "returns 404 for non project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member)
expect(response).to have_http_status(404)
end
- it "should return 404 for project members with guest role" do
+ it "returns 404 for project members with guest role" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest)
expect(response).to have_http_status(404)
end
- it "should return confidential issue for project members" do
+ it "returns confidential issue for project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
- it "should return confidential issue for author" do
+ it "returns confidential issue for author" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", author)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
- it "should return confidential issue for assignee" do
+ it "returns confidential issue for assignee" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", assignee)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
expect(json_response['iid']).to eq(confidential_issue.iid)
end
- it "should return confidential issue for admin" do
+ it "returns confidential issue for admin" do
get api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(confidential_issue.title)
@@ -468,7 +468,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/issues" do
- it "should create a new project issue" do
+ it "creates a new project issue" do
post api("/projects/#{project.id}/issues", user),
title: 'new issue', labels: 'label, label2'
expect(response).to have_http_status(201)
@@ -477,12 +477,12 @@ describe API::API, api: true do
expect(json_response['labels']).to eq(['label', 'label2'])
end
- it "should return a 400 bad request if title not given" do
+ it "returns a 400 bad request if title not given" do
post api("/projects/#{project.id}/issues", user), labels: 'label, label2'
expect(response).to have_http_status(400)
end
- it 'should allow special label names' do
+ it 'allows special label names' do
post api("/projects/#{project.id}/issues", user),
title: 'new issue',
labels: 'label, label?, label&foo, ?, &'
@@ -494,7 +494,7 @@ describe API::API, api: true do
expect(json_response['labels']).to include '&'
end
- it 'should return 400 if title is too long' do
+ it 'returns 400 if title is too long' do
post api("/projects/#{project.id}/issues", user),
title: 'g' * 256
expect(response).to have_http_status(400)
@@ -543,7 +543,7 @@ describe API::API, api: true do
}
end
- it "should not create a new project issue" do
+ it "does not create a new project issue" do
expect { post api("/projects/#{project.id}/issues", user), params }.not_to change(Issue, :count)
expect(response).to have_http_status(400)
expect(json_response['message']).to eq({ "error" => "Spam detected" })
@@ -559,7 +559,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/issues/:issue_id to update only title" do
- it "should update a project issue" do
+ it "updates a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
@@ -567,13 +567,13 @@ describe API::API, api: true do
expect(json_response['title']).to eq('updated title')
end
- it "should return 404 error if issue id not found" do
+ it "returns 404 error if issue id not found" do
put api("/projects/#{project.id}/issues/44444", user),
title: 'updated title'
expect(response).to have_http_status(404)
end
- it 'should allow special label names' do
+ it 'allows special label names' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title',
labels: 'label, label?, label&foo, ?, &'
@@ -587,33 +587,33 @@ describe API::API, api: true do
end
context 'confidential issues' do
- it "should return 403 for non project members" do
+ it "returns 403 for non project members" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member),
title: 'updated title'
expect(response).to have_http_status(403)
end
- it "should return 403 for project members with guest role" do
+ it "returns 403 for project members with guest role" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest),
title: 'updated title'
expect(response).to have_http_status(403)
end
- it "should update a confidential issue for project members" do
+ it "updates a confidential issue for project members" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['title']).to eq('updated title')
end
- it "should update a confidential issue for author" do
+ it "updates a confidential issue for author" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", author),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['title']).to eq('updated title')
end
- it "should update a confidential issue for admin" do
+ it "updates a confidential issue for admin" do
put api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin),
title: 'updated title'
expect(response).to have_http_status(200)
@@ -626,21 +626,21 @@ describe API::API, api: true do
let!(:label) { create(:label, title: 'dummy', project: project) }
let!(:label_link) { create(:label_link, label: label, target: issue) }
- it 'should not update labels if not present' do
+ it 'does not update labels if not present' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['labels']).to eq([label.title])
end
- it 'should remove all labels' do
+ it 'removes all labels' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: ''
expect(response).to have_http_status(200)
expect(json_response['labels']).to eq([])
end
- it 'should update labels' do
+ it 'updates labels' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'foo,bar'
expect(response).to have_http_status(200)
@@ -648,7 +648,7 @@ describe API::API, api: true do
expect(json_response['labels']).to include 'bar'
end
- it 'should allow special label names' do
+ it 'allows special label names' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&'
expect(response.status).to eq(200)
@@ -662,7 +662,7 @@ describe API::API, api: true do
expect(json_response['labels']).to include '&'
end
- it 'should return 400 if title is too long' do
+ it 'returns 400 if title is too long' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'g' * 256
expect(response).to have_http_status(400)
@@ -673,7 +673,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/issues/:issue_id to update state and label" do
- it "should update a project issue" do
+ it "updates a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label2', state_event: "close"
expect(response).to have_http_status(200)
diff --git a/spec/requests/api/keys_spec.rb b/spec/requests/api/keys_spec.rb
index 1861882d59e..893ed5c2b10 100644
--- a/spec/requests/api/keys_spec.rb
+++ b/spec/requests/api/keys_spec.rb
@@ -12,20 +12,20 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/keys/#{key.id}")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return 404 for non-existing key' do
+ it 'returns 404 for non-existing key' do
get api('/keys/999999', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it 'should return single ssh key with user information' do
+ it 'returns single ssh key with user information' do
user.keys << key
user.save
get api("/keys/#{key.id}", admin)
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb
index 63636b4a1b6..83789223019 100644
--- a/spec/requests/api/labels_spec.rb
+++ b/spec/requests/api/labels_spec.rb
@@ -12,7 +12,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/labels' do
- it 'should return project labels' do
+ it 'returns project labels' do
get api("/projects/#{project.id}/labels", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -22,7 +22,7 @@ describe API::API, api: true do
end
describe 'POST /projects/:id/labels' do
- it 'should return created label when all params' do
+ it 'returns created label when all params' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAABB',
@@ -33,7 +33,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq('test')
end
- it 'should return created label when only required params' do
+ it 'returns created label when only required params' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo & Bar',
color: '#FFAABB'
@@ -43,17 +43,17 @@ describe API::API, api: true do
expect(json_response['description']).to be_nil
end
- it 'should return a 400 bad request if name not given' do
+ it 'returns a 400 bad request if name not given' do
post api("/projects/#{project.id}/labels", user), color: '#FFAABB'
expect(response).to have_http_status(400)
end
- it 'should return a 400 bad request if color not given' do
+ it 'returns a 400 bad request if color not given' do
post api("/projects/#{project.id}/labels", user), name: 'Foobar'
expect(response).to have_http_status(400)
end
- it 'should return 400 for invalid color' do
+ it 'returns 400 for invalid color' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAA'
@@ -61,7 +61,7 @@ describe API::API, api: true do
expect(json_response['message']['color']).to eq(['must be a valid color code'])
end
- it 'should return 400 for too long color code' do
+ it 'returns 400 for too long color code' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAAFFFF'
@@ -69,7 +69,7 @@ describe API::API, api: true do
expect(json_response['message']['color']).to eq(['must be a valid color code'])
end
- it 'should return 400 for invalid name' do
+ it 'returns 400 for invalid name' do
post api("/projects/#{project.id}/labels", user),
name: ',',
color: '#FFAABB'
@@ -77,7 +77,7 @@ describe API::API, api: true do
expect(json_response['message']['title']).to eq(['is invalid'])
end
- it 'should return 409 if label already exists' do
+ it 'returns 409 if label already exists' do
post api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FFAABB'
@@ -87,25 +87,25 @@ describe API::API, api: true do
end
describe 'DELETE /projects/:id/labels' do
- it 'should return 200 for existing label' do
+ it 'returns 200 for existing label' do
delete api("/projects/#{project.id}/labels", user), name: 'label1'
expect(response).to have_http_status(200)
end
- it 'should return 404 for non existing label' do
+ it 'returns 404 for non existing label' do
delete api("/projects/#{project.id}/labels", user), name: 'label2'
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Label Not Found')
end
- it 'should return 400 for wrong parameters' do
+ it 'returns 400 for wrong parameters' do
delete api("/projects/#{project.id}/labels", user)
expect(response).to have_http_status(400)
end
end
describe 'PUT /projects/:id/labels' do
- it 'should return 200 if name and colors and description are changed' do
+ it 'returns 200 if name and colors and description are changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
new_name: 'New Label',
@@ -117,7 +117,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq('test')
end
- it 'should return 200 if name is changed' do
+ it 'returns 200 if name is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
new_name: 'New Label'
@@ -126,7 +126,7 @@ describe API::API, api: true do
expect(json_response['color']).to eq(label1.color)
end
- it 'should return 200 if colors is changed' do
+ it 'returns 200 if colors is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FFFFFF'
@@ -135,7 +135,7 @@ describe API::API, api: true do
expect(json_response['color']).to eq('#FFFFFF')
end
- it 'should return 200 if description is changed' do
+ it 'returns 200 if description is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
description: 'test'
@@ -144,27 +144,27 @@ describe API::API, api: true do
expect(json_response['description']).to eq('test')
end
- it 'should return 404 if label does not exist' do
+ it 'returns 404 if label does not exist' do
put api("/projects/#{project.id}/labels", user),
name: 'label2',
new_name: 'label3'
expect(response).to have_http_status(404)
end
- it 'should return 400 if no label name given' do
+ it 'returns 400 if no label name given' do
put api("/projects/#{project.id}/labels", user), new_name: 'label2'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "name" not given')
end
- it 'should return 400 if no new parameters given' do
+ it 'returns 400 if no new parameters given' do
put api("/projects/#{project.id}/labels", user), name: 'label1'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('Required parameters '\
'"new_name" or "color" missing')
end
- it 'should return 400 for invalid name' do
+ it 'returns 400 for invalid name' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
new_name: ',',
@@ -173,7 +173,7 @@ describe API::API, api: true do
expect(json_response['message']['title']).to eq(['is invalid'])
end
- it 'should return 400 when color code is too short' do
+ it 'returns 400 when color code is too short' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FF'
@@ -181,7 +181,7 @@ describe API::API, api: true do
expect(json_response['message']['color']).to eq(['must be a valid color code'])
end
- it 'should return 400 for too long color code' do
+ it 'returns 400 for too long color code' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAAFFFF'
@@ -192,7 +192,7 @@ describe API::API, api: true do
describe "POST /projects/:id/labels/:label_id/subscription" do
context "when label_id is a label title" do
- it "should subscribe to the label" do
+ it "subscribes to the label" do
post api("/projects/#{project.id}/labels/#{label1.title}/subscription", user)
expect(response).to have_http_status(201)
@@ -202,7 +202,7 @@ describe API::API, api: true do
end
context "when label_id is a label ID" do
- it "should subscribe to the label" do
+ it "subscribes to the label" do
post api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(201)
@@ -214,7 +214,7 @@ describe API::API, api: true do
context "when user is already subscribed to label" do
before { label1.subscribe(user) }
- it "should return 304" do
+ it "returns 304" do
post api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(304)
@@ -222,7 +222,7 @@ describe API::API, api: true do
end
context "when label ID is not found" do
- it "should a return 404 error" do
+ it "returns 404 error" do
post api("/projects/#{project.id}/labels/1234/subscription", user)
expect(response).to have_http_status(404)
@@ -234,7 +234,7 @@ describe API::API, api: true do
before { label1.subscribe(user) }
context "when label_id is a label title" do
- it "should unsubscribe from the label" do
+ it "unsubscribes from the label" do
delete api("/projects/#{project.id}/labels/#{label1.title}/subscription", user)
expect(response).to have_http_status(200)
@@ -244,7 +244,7 @@ describe API::API, api: true do
end
context "when label_id is a label ID" do
- it "should unsubscribe from the label" do
+ it "unsubscribes from the label" do
delete api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(200)
@@ -256,7 +256,7 @@ describe API::API, api: true do
context "when user is already unsubscribed from label" do
before { label1.unsubscribe(user) }
- it "should return 304" do
+ it "returns 304" do
delete api("/projects/#{project.id}/labels/#{label1.id}/subscription", user)
expect(response).to have_http_status(304)
@@ -264,7 +264,7 @@ describe API::API, api: true do
end
context "when label ID is not found" do
- it "should a return 404 error" do
+ it "returns 404 error" do
delete api("/projects/#{project.id}/labels/1234/subscription", user)
expect(response).to have_http_status(404)
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 651b91e9f68..617600d6173 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -20,14 +20,14 @@ describe API::API, api: true do
describe "GET /projects/:id/merge_requests" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/projects/#{project.id}/merge_requests")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return an array of all merge_requests" do
+ it "returns an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -35,7 +35,7 @@ describe API::API, api: true do
expect(json_response.last['title']).to eq(merge_request.title)
end
- it "should return an array of all merge_requests" do
+ it "returns an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests?state", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -43,7 +43,7 @@ describe API::API, api: true do
expect(json_response.last['title']).to eq(merge_request.title)
end
- it "should return an array of open merge_requests" do
+ it "returns an array of open merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=opened", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -51,7 +51,7 @@ describe API::API, api: true do
expect(json_response.last['title']).to eq(merge_request.title)
end
- it "should return an array of closed merge_requests" do
+ it "returns an array of closed merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=closed", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -59,7 +59,7 @@ describe API::API, api: true do
expect(json_response.first['title']).to eq(merge_request_closed.title)
end
- it "should return an array of merged merge_requests" do
+ it "returns an array of merged merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=merged", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -73,7 +73,7 @@ describe API::API, api: true do
@mr_earlier = mr_with_earlier_created_and_updated_at_time
end
- it "should return an array of merge_requests in ascending order" do
+ it "returns an array of merge_requests in ascending order" do
get api("/projects/#{project.id}/merge_requests?sort=asc", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -82,7 +82,7 @@ describe API::API, api: true do
expect(response_dates).to eq(response_dates.sort)
end
- it "should return an array of merge_requests in descending order" do
+ it "returns an array of merge_requests in descending order" do
get api("/projects/#{project.id}/merge_requests?sort=desc", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -91,7 +91,7 @@ describe API::API, api: true do
expect(response_dates).to eq(response_dates.sort.reverse)
end
- it "should return an array of merge_requests ordered by updated_at" do
+ it "returns an array of merge_requests ordered by updated_at" do
get api("/projects/#{project.id}/merge_requests?order_by=updated_at", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -100,7 +100,7 @@ describe API::API, api: true do
expect(response_dates).to eq(response_dates.sort.reverse)
end
- it "should return an array of merge_requests ordered by created_at" do
+ it "returns an array of merge_requests ordered by created_at" do
get api("/projects/#{project.id}/merge_requests?order_by=created_at&sort=asc", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -142,7 +142,7 @@ describe API::API, api: true do
expect(json_response['force_close_merge_request']).to be_falsy
end
- it "should return merge_request" do
+ it "returns merge_request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(merge_request.title)
@@ -153,7 +153,7 @@ describe API::API, api: true do
expect(json_response['force_close_merge_request']).to be_falsy
end
- it 'should return merge_request by iid' do
+ it 'returns merge_request by iid' do
url = "/projects/#{project.id}/merge_requests?iid=#{merge_request.iid}"
get api(url, user)
expect(response.status).to eq 200
@@ -161,7 +161,7 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq merge_request.id
end
- it "should return a 404 error if merge_request_id not found" do
+ it "returns a 404 error if merge_request_id not found" do
get api("/projects/#{project.id}/merge_requests/999", user)
expect(response).to have_http_status(404)
end
@@ -169,7 +169,7 @@ describe API::API, api: true do
context 'Work in Progress' do
let!(:merge_request_wip) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "WIP: Test", created_at: base_time + 1.second) }
- it "should return merge_request" do
+ it "returns merge_request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request_wip.id}", user)
expect(response).to have_http_status(200)
expect(json_response['work_in_progress']).to eq(true)
@@ -195,7 +195,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/merge_requests/:merge_request_id/changes' do
- it 'should return the change information of the merge_request' do
+ it 'returns the change information of the merge_request' do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/changes", user)
expect(response.status).to eq 200
expect(json_response['changes'].size).to eq(merge_request.diffs.size)
@@ -209,7 +209,7 @@ describe API::API, api: true do
describe "POST /projects/:id/merge_requests" do
context 'between branches projects' do
- it "should return merge_request" do
+ it "returns merge_request" do
post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request',
source_branch: 'feature_conflict',
@@ -223,31 +223,31 @@ describe API::API, api: true do
expect(json_response['milestone']['id']).to eq(milestone.id)
end
- it "should return 422 when source_branch equals target_branch" do
+ it "returns 422 when source_branch equals target_branch" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "master", target_branch: "master", author: user
expect(response).to have_http_status(422)
end
- it "should return 400 when source_branch is missing" do
+ it "returns 400 when source_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", target_branch: "master", author: user
expect(response).to have_http_status(400)
end
- it "should return 400 when target_branch is missing" do
+ it "returns 400 when target_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "markdown", author: user
expect(response).to have_http_status(400)
end
- it "should return 400 when title is missing" do
+ it "returns 400 when title is missing" do
post api("/projects/#{project.id}/merge_requests", user),
target_branch: 'master', source_branch: 'markdown'
expect(response).to have_http_status(400)
end
- it 'should allow special label names' do
+ it 'allows special label names' do
post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request',
source_branch: 'markdown',
@@ -272,7 +272,7 @@ describe API::API, api: true do
@mr = MergeRequest.all.last
end
- it 'should return 409 when MR already exists for source/target' do
+ it 'returns 409 when MR already exists for source/target' do
expect do
post api("/projects/#{project.id}/merge_requests", user),
title: 'New test merge_request',
@@ -294,7 +294,7 @@ describe API::API, api: true do
fork_project.team << [user2, :reporters]
end
- it "should return merge_request" do
+ it "returns merge_request" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master",
author: user2, target_project_id: project.id, description: 'Test description for Test merge_request'
@@ -303,7 +303,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq('Test description for Test merge_request')
end
- it "should not return 422 when source_branch equals target_branch" do
+ it "does not return 422 when source_branch equals target_branch" do
expect(project.id).not_to eq(fork_project.id)
expect(fork_project.forked?).to be_truthy
expect(fork_project.forked_from_project).to eq(project)
@@ -313,26 +313,26 @@ describe API::API, api: true do
expect(json_response['title']).to eq('Test merge_request')
end
- it "should return 400 when source_branch is missing" do
+ it "returns 400 when source_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
expect(response).to have_http_status(400)
end
- it "should return 400 when target_branch is missing" do
+ it "returns 400 when target_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
expect(response).to have_http_status(400)
end
- it "should return 400 when title is missing" do
+ it "returns 400 when title is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: project.id
expect(response).to have_http_status(400)
end
context 'when target_branch is specified' do
- it 'should return 422 if not a forked project' do
+ it 'returns 422 if not a forked project' do
post api("/projects/#{project.id}/merge_requests", user),
title: 'Test merge_request',
target_branch: 'master',
@@ -342,7 +342,7 @@ describe API::API, api: true do
expect(response).to have_http_status(422)
end
- it 'should return 422 if targeting a different fork' do
+ it 'returns 422 if targeting a different fork' do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request',
target_branch: 'master',
@@ -353,7 +353,7 @@ describe API::API, api: true do
end
end
- it "should return 201 when target_branch is specified and for the same project" do
+ it "returns 201 when target_branch is specified and for the same project" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: fork_project.id
expect(response).to have_http_status(201)
@@ -385,7 +385,7 @@ describe API::API, api: true do
end
describe "PUT /projects/:id/merge_requests/:merge_request_id to close MR" do
- it "should return merge_request" do
+ it "returns merge_request" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: "close"
expect(response).to have_http_status(200)
expect(json_response['state']).to eq('closed')
@@ -395,13 +395,13 @@ describe API::API, api: true do
describe "PUT /projects/:id/merge_requests/:merge_request_id/merge" do
let(:pipeline) { create(:ci_pipeline_without_jobs) }
- it "should return merge_request in case of success" do
+ it "returns merge_request in case of success" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user)
expect(response).to have_http_status(200)
end
- it "should return 406 if branch can't be merged" do
+ it "returns 406 if branch can't be merged" do
allow_any_instance_of(MergeRequest).
to receive(:can_be_merged?).and_return(false)
@@ -411,14 +411,14 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Branch cannot be merged')
end
- it "should return 405 if merge_request is not open" do
+ it "returns 405 if merge_request is not open" do
merge_request.close
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user)
expect(response).to have_http_status(405)
expect(json_response['message']).to eq('405 Method Not Allowed')
end
- it "should return 405 if merge_request is a work in progress" do
+ it "returns 405 if merge_request is a work in progress" do
merge_request.update_attribute(:title, "WIP: #{merge_request.title}")
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user)
expect(response).to have_http_status(405)
@@ -434,7 +434,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('405 Method Not Allowed')
end
- it "should return 401 if user has no permissions to merge" do
+ it "returns 401 if user has no permissions to merge" do
user2 = create(:user)
project.team << [user2, :reporter]
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user2)
@@ -486,19 +486,19 @@ describe API::API, api: true do
expect(json_response['milestone']['id']).to eq(milestone.id)
end
- it "should return 400 when source_branch is specified" do
+ it "returns 400 when source_branch is specified" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user),
source_branch: "master", target_branch: "master"
expect(response).to have_http_status(400)
end
- it "should return merge_request with renamed target_branch" do
+ it "returns merge_request with renamed target_branch" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), target_branch: "wiki"
expect(response).to have_http_status(200)
expect(json_response['target_branch']).to eq('wiki')
end
- it 'should allow special label names' do
+ it 'allows special label names' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}",
user),
title: 'new issue',
@@ -513,7 +513,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/merge_requests/:merge_request_id/comments" do
- it "should return comment" do
+ it "returns comment" do
original_count = merge_request.notes.size
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user), note: "My comment"
@@ -524,12 +524,12 @@ describe API::API, api: true do
expect(merge_request.notes.size).to eq(original_count + 1)
end
- it "should return 400 if note is missing" do
+ it "returns 400 if note is missing" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user)
expect(response).to have_http_status(400)
end
- it "should return 404 if note is attached to non existent merge request" do
+ it "returns 404 if note is attached to non existent merge request" do
post api("/projects/#{project.id}/merge_requests/404/comments", user),
note: 'My comment'
expect(response).to have_http_status(404)
@@ -537,7 +537,7 @@ describe API::API, api: true do
end
describe "GET :id/merge_requests/:merge_request_id/comments" do
- it "should return merge_request comments ordered by created_at" do
+ it "returns merge_request comments ordered by created_at" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -547,7 +547,7 @@ describe API::API, api: true do
expect(json_response.last['note']).to eq("another comment on a MR")
end
- it "should return a 404 error if merge_request_id not found" do
+ it "returns a 404 error if merge_request_id not found" do
get api("/projects/#{project.id}/merge_requests/999/comments", user)
expect(response).to have_http_status(404)
end
diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb
index 0f4e38b2475..d6a0c656e74 100644
--- a/spec/requests/api/milestones_spec.rb
+++ b/spec/requests/api/milestones_spec.rb
@@ -10,14 +10,14 @@ describe API::API, api: true do
before { project.team << [user, :developer] }
describe 'GET /projects/:id/milestones' do
- it 'should return project milestones' do
+ it 'returns project milestones' do
get api("/projects/#{project.id}/milestones", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(milestone.title)
end
- it 'should return a 401 error if user not authenticated' do
+ it 'returns a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones")
expect(response).to have_http_status(401)
end
@@ -42,14 +42,14 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/milestones/:milestone_id' do
- it 'should return a project milestone by id' do
+ it 'returns a project milestone by id' do
get api("/projects/#{project.id}/milestones/#{milestone.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(milestone.title)
expect(json_response['iid']).to eq(milestone.iid)
end
- it 'should return a project milestone by iid' do
+ it 'returns a project milestone by iid' do
get api("/projects/#{project.id}/milestones?iid=#{closed_milestone.iid}", user)
expect(response.status).to eq 200
@@ -58,26 +58,26 @@ describe API::API, api: true do
expect(json_response.first['id']).to eq closed_milestone.id
end
- it 'should return 401 error if user not authenticated' do
+ it 'returns 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}")
expect(response).to have_http_status(401)
end
- it 'should return a 404 error if milestone id not found' do
+ it 'returns a 404 error if milestone id not found' do
get api("/projects/#{project.id}/milestones/1234", user)
expect(response).to have_http_status(404)
end
end
describe 'POST /projects/:id/milestones' do
- it 'should create a new project milestone' do
+ it 'creates a new project milestone' do
post api("/projects/#{project.id}/milestones", user), title: 'new milestone'
expect(response).to have_http_status(201)
expect(json_response['title']).to eq('new milestone')
expect(json_response['description']).to be_nil
end
- it 'should create a new project milestone with description and due date' do
+ it 'creates a new project milestone with description and due date' do
post api("/projects/#{project.id}/milestones", user),
title: 'new milestone', description: 'release', due_date: '2013-03-02'
expect(response).to have_http_status(201)
@@ -85,21 +85,21 @@ describe API::API, api: true do
expect(json_response['due_date']).to eq('2013-03-02')
end
- it 'should return a 400 error if title is missing' do
+ it 'returns a 400 error if title is missing' do
post api("/projects/#{project.id}/milestones", user)
expect(response).to have_http_status(400)
end
end
describe 'PUT /projects/:id/milestones/:milestone_id' do
- it 'should update a project milestone' do
+ it 'updates a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
title: 'updated title'
expect(response).to have_http_status(200)
expect(json_response['title']).to eq('updated title')
end
- it 'should return a 404 error if milestone id not found' do
+ it 'returns a 404 error if milestone id not found' do
put api("/projects/#{project.id}/milestones/1234", user),
title: 'updated title'
expect(response).to have_http_status(404)
@@ -107,7 +107,7 @@ describe API::API, api: true do
end
describe 'PUT /projects/:id/milestones/:milestone_id to close milestone' do
- it 'should update a project milestone' do
+ it 'updates a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
state_event: 'close'
expect(response).to have_http_status(200)
@@ -117,7 +117,7 @@ describe API::API, api: true do
end
describe 'PUT /projects/:id/milestones/:milestone_id to test observer on close' do
- it 'should create an activity event when an milestone is closed' do
+ it 'creates an activity event when an milestone is closed' do
expect(Event).to receive(:create)
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
@@ -129,14 +129,14 @@ describe API::API, api: true do
before do
milestone.issues << create(:issue, project: project)
end
- it 'should return project issues for a particular milestone' do
+ it 'returns project issues for a particular milestone' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first['milestone']['title']).to eq(milestone.title)
end
- it 'should return a 401 error if user not authenticated' do
+ it 'returns a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues")
expect(response).to have_http_status(401)
end
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb
index 237b4b17eb5..5347cf4f7bc 100644
--- a/spec/requests/api/namespaces_spec.rb
+++ b/spec/requests/api/namespaces_spec.rb
@@ -9,14 +9,14 @@ describe API::API, api: true do
describe "GET /namespaces" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/namespaces")
expect(response).to have_http_status(401)
end
end
context "when authenticated as admin" do
- it "admin: should return an array of all namespaces" do
+ it "admin: returns an array of all namespaces" do
get api("/namespaces", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -24,7 +24,7 @@ describe API::API, api: true do
expect(json_response.length).to eq(Namespace.count)
end
- it "admin: should return an array of matched namespaces" do
+ it "admin: returns an array of matched namespaces" do
get api("/namespaces?search=#{group1.name}", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -34,7 +34,7 @@ describe API::API, api: true do
end
context "when authenticated as a regular user" do
- it "user: should return an array of namespaces" do
+ it "user: returns an array of namespaces" do
get api("/namespaces", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -42,7 +42,7 @@ describe API::API, api: true do
expect(json_response.length).to eq(1)
end
- it "admin: should return an array of matched namespaces" do
+ it "admin: returns an array of matched namespaces" do
get api("/namespaces?search=#{user.username}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index 65c53211dd3..737fa14cbb0 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -37,7 +37,7 @@ describe API::API, api: true do
end
context "when noteable is an Issue" do
- it "should return an array of issue notes" do
+ it "returns an array of issue notes" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes", user)
expect(response).to have_http_status(200)
@@ -45,14 +45,14 @@ describe API::API, api: true do
expect(json_response.first['body']).to eq(issue_note.note)
end
- it "should return a 404 error when issue id not found" do
+ it "returns a 404 error when issue id not found" do
get api("/projects/#{project.id}/issues/12345/notes", user)
expect(response).to have_http_status(404)
end
context "and current user cannot view the notes" do
- it "should return an empty array" do
+ it "returns an empty array" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", user)
expect(response).to have_http_status(200)
@@ -71,7 +71,7 @@ describe API::API, api: true do
end
context "and current user can view the note" do
- it "should return an empty array" do
+ it "returns an empty array" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", private_user)
expect(response).to have_http_status(200)
@@ -83,7 +83,7 @@ describe API::API, api: true do
end
context "when noteable is a Snippet" do
- it "should return an array of snippet notes" do
+ it "returns an array of snippet notes" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user)
expect(response).to have_http_status(200)
@@ -91,7 +91,7 @@ describe API::API, api: true do
expect(json_response.first['body']).to eq(snippet_note.note)
end
- it "should return a 404 error when snippet id not found" do
+ it "returns a 404 error when snippet id not found" do
get api("/projects/#{project.id}/snippets/42/notes", user)
expect(response).to have_http_status(404)
@@ -105,7 +105,7 @@ describe API::API, api: true do
end
context "when noteable is a Merge Request" do
- it "should return an array of merge_requests notes" do
+ it "returns an array of merge_requests notes" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes", user)
expect(response).to have_http_status(200)
@@ -113,7 +113,7 @@ describe API::API, api: true do
expect(json_response.first['body']).to eq(merge_request_note.note)
end
- it "should return a 404 error if merge request id not found" do
+ it "returns a 404 error if merge request id not found" do
get api("/projects/#{project.id}/merge_requests/4444/notes", user)
expect(response).to have_http_status(404)
@@ -129,21 +129,21 @@ describe API::API, api: true do
describe "GET /projects/:id/noteable/:noteable_id/notes/:note_id" do
context "when noteable is an Issue" do
- it "should return an issue note by id" do
+ it "returns an issue note by id" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/#{issue_note.id}", user)
expect(response).to have_http_status(200)
expect(json_response['body']).to eq(issue_note.note)
end
- it "should return a 404 error if issue note not found" do
+ it "returns a 404 error if issue note not found" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user)
expect(response).to have_http_status(404)
end
context "and current user cannot view the note" do
- it "should return a 404 error" do
+ it "returns a 404 error" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", user)
expect(response).to have_http_status(404)
@@ -160,7 +160,7 @@ describe API::API, api: true do
end
context "and current user can view the note" do
- it "should return an issue note by id" do
+ it "returns an issue note by id" do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", private_user)
expect(response).to have_http_status(200)
@@ -171,14 +171,14 @@ describe API::API, api: true do
end
context "when noteable is a Snippet" do
- it "should return a snippet note by id" do
+ it "returns a snippet note by id" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user)
expect(response).to have_http_status(200)
expect(json_response['body']).to eq(snippet_note.note)
end
- it "should return a 404 error if snippet note not found" do
+ it "returns a 404 error if snippet note not found" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/12345", user)
expect(response).to have_http_status(404)
@@ -188,7 +188,7 @@ describe API::API, api: true do
describe "POST /projects/:id/noteable/:noteable_id/notes" do
context "when noteable is an Issue" do
- it "should create a new issue note" do
+ it "creates a new issue note" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!'
expect(response).to have_http_status(201)
@@ -196,13 +196,13 @@ describe API::API, api: true do
expect(json_response['author']['username']).to eq(user.username)
end
- it "should return a 400 bad request error if body not given" do
+ it "returns a 400 bad request error if body not given" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user)
expect(response).to have_http_status(400)
end
- it "should return a 401 unauthorized error if user not authenticated" do
+ it "returns a 401 unauthorized error if user not authenticated" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes"), body: 'hi!'
expect(response).to have_http_status(401)
@@ -223,7 +223,7 @@ describe API::API, api: true do
end
context "when noteable is a Snippet" do
- it "should create a new snippet note" do
+ it "creates a new snippet note" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user), body: 'hi!'
expect(response).to have_http_status(201)
@@ -231,13 +231,13 @@ describe API::API, api: true do
expect(json_response['author']['username']).to eq(user.username)
end
- it "should return a 400 bad request error if body not given" do
+ it "returns a 400 bad request error if body not given" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user)
expect(response).to have_http_status(400)
end
- it "should return a 401 unauthorized error if user not authenticated" do
+ it "returns a 401 unauthorized error if user not authenticated" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes"), body: 'hi!'
expect(response).to have_http_status(401)
@@ -267,7 +267,7 @@ describe API::API, api: true do
end
describe "POST /projects/:id/noteable/:noteable_id/notes to test observer on create" do
- it "should create an activity event when an issue note is created" do
+ it "creates an activity event when an issue note is created" do
expect(Event).to receive(:create)
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!'
@@ -276,7 +276,7 @@ describe API::API, api: true do
describe 'PUT /projects/:id/noteable/:noteable_id/notes/:note_id' do
context 'when noteable is an Issue' do
- it 'should return modified note' do
+ it 'returns modified note' do
put api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user), body: 'Hello!'
@@ -284,14 +284,14 @@ describe API::API, api: true do
expect(json_response['body']).to eq('Hello!')
end
- it 'should return a 404 error when note id not found' do
+ it 'returns a 404 error when note id not found' do
put api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user),
body: 'Hello!'
expect(response).to have_http_status(404)
end
- it 'should return a 400 bad request error if body not given' do
+ it 'returns a 400 bad request error if body not given' do
put api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
@@ -300,7 +300,7 @@ describe API::API, api: true do
end
context 'when noteable is a Snippet' do
- it 'should return modified note' do
+ it 'returns modified note' do
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user), body: 'Hello!'
@@ -308,7 +308,7 @@ describe API::API, api: true do
expect(json_response['body']).to eq('Hello!')
end
- it 'should return a 404 error when note id not found' do
+ it 'returns a 404 error when note id not found' do
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/12345", user), body: "Hello!"
@@ -317,7 +317,7 @@ describe API::API, api: true do
end
context 'when noteable is a Merge Request' do
- it 'should return modified note' do
+ it 'returns modified note' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
"notes/#{merge_request_note.id}", user), body: 'Hello!'
@@ -325,7 +325,7 @@ describe API::API, api: true do
expect(json_response['body']).to eq('Hello!')
end
- it 'should return a 404 error when note id not found' do
+ it 'returns a 404 error when note id not found' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
"notes/12345", user), body: "Hello!"
diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb
index 504deed81f9..92c38e69283 100644
--- a/spec/requests/api/project_hooks_spec.rb
+++ b/spec/requests/api/project_hooks_spec.rb
@@ -21,7 +21,7 @@ describe API::API, 'ProjectHooks', api: true do
describe "GET /projects/:id/hooks" do
context "authorized user" do
- it "should return project hooks" do
+ it "returns project hooks" do
get api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(200)
@@ -40,7 +40,7 @@ describe API::API, 'ProjectHooks', api: true do
end
context "unauthorized user" do
- it "should not access project hooks" do
+ it "does not access project hooks" do
get api("/projects/#{project.id}/hooks", user3)
expect(response).to have_http_status(403)
end
@@ -49,7 +49,7 @@ describe API::API, 'ProjectHooks', api: true do
describe "GET /projects/:id/hooks/:hook_id" do
context "authorized user" do
- it "should return a project hook" do
+ it "returns a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(200)
expect(json_response['url']).to eq(hook.url)
@@ -61,27 +61,27 @@ describe API::API, 'ProjectHooks', api: true do
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
end
- it "should return a 404 error if hook id is not available" do
+ it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_http_status(404)
end
end
context "unauthorized user" do
- it "should not access an existing hook" do
+ it "does not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
expect(response).to have_http_status(403)
end
end
- it "should return a 404 error if hook id is not available" do
+ it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_http_status(404)
end
end
describe "POST /projects/:id/hooks" do
- it "should add hook to project" do
+ it "adds hook to project" do
expect do
post api("/projects/#{project.id}/hooks", user), url: "http://example.com", issues_events: true
end.to change {project.hooks.count}.by(1)
@@ -97,19 +97,19 @@ describe API::API, 'ProjectHooks', api: true do
expect(json_response['enable_ssl_verification']).to eq(true)
end
- it "should return a 400 error if url not given" do
+ it "returns a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(400)
end
- it "should return a 422 error if url not valid" do
+ it "returns a 422 error if url not valid" do
post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com"
expect(response).to have_http_status(422)
end
end
describe "PUT /projects/:id/hooks/:hook_id" do
- it "should update an existing project hook" do
+ it "updates an existing project hook" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user),
url: 'http://example.org', push_events: false
expect(response).to have_http_status(200)
@@ -122,46 +122,46 @@ describe API::API, 'ProjectHooks', api: true do
expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
end
- it "should return 404 error if hook id not found" do
+ it "returns 404 error if hook id not found" do
put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org'
expect(response).to have_http_status(404)
end
- it "should return 400 error if url is not given" do
+ it "returns 400 error if url is not given" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(400)
end
- it "should return a 422 error if url is not valid" do
+ it "returns a 422 error if url is not valid" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com'
expect(response).to have_http_status(422)
end
end
describe "DELETE /projects/:id/hooks/:hook_id" do
- it "should delete hook from project" do
+ it "deletes hook from project" do
expect do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
end.to change {project.hooks.count}.by(-1)
expect(response).to have_http_status(200)
end
- it "should return success when deleting hook" do
+ it "returns success when deleting hook" do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(200)
end
- it "should return a 404 error when deleting non existent hook" do
+ it "returns a 404 error when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user)
expect(response).to have_http_status(404)
end
- it "should return a 405 error if hook id not given" do
+ it "returns a 405 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(405)
end
- it "shold return a 404 if a user attempts to delete project hooks he/she does not own" do
+ it "returns a 404 if a user attempts to delete project hooks he/she does not own" do
test_user = create(:user)
other_project = create(:project)
other_project.team << [test_user, :master]
diff --git a/spec/requests/api/project_members_spec.rb b/spec/requests/api/project_members_spec.rb
index 9a7c1da4401..13cc0d81ac8 100644
--- a/spec/requests/api/project_members_spec.rb
+++ b/spec/requests/api/project_members_spec.rb
@@ -13,7 +13,7 @@ describe API::API, api: true do
before { project_member }
before { project_member2 }
- it "should return project team members" do
+ it "returns project team members" do
get api("/projects/#{project.id}/members", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -29,7 +29,7 @@ describe API::API, api: true do
expect(json_response.first['username']).to eq(user.username)
end
- it "should return a 404 error if id not found" do
+ it "returns a 404 error if id not found" do
get api("/projects/9999/members", user)
expect(response).to have_http_status(404)
end
@@ -38,21 +38,21 @@ describe API::API, api: true do
describe "GET /projects/:id/members/:user_id" do
before { project_member }
- it "should return project team member" do
+ it "returns project team member" do
get api("/projects/#{project.id}/members/#{user.id}", user)
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user.username)
expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end
- it "should return a 404 error if user id not found" do
+ it "returns a 404 error if user id not found" do
get api("/projects/#{project.id}/members/1234", user)
expect(response).to have_http_status(404)
end
end
describe "POST /projects/:id/members" do
- it "should add user to project team" do
+ it "adds user to project team" do
expect do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
end.to change { ProjectMember.count }.by(1)
@@ -62,7 +62,7 @@ describe API::API, api: true do
expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end
- it "should return a 201 status if user is already project member" do
+ it "returns a 201 status if user is already project member" do
post api("/projects/#{project.id}/members", user),
user_id: user2.id,
access_level: ProjectMember::DEVELOPER
@@ -75,17 +75,17 @@ describe API::API, api: true do
expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end
- it "should return a 400 error when user id is not given" do
+ it "returns a 400 error when user id is not given" do
post api("/projects/#{project.id}/members", user), access_level: ProjectMember::MASTER
expect(response).to have_http_status(400)
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
post api("/projects/#{project.id}/members", user), user_id: user2.id
expect(response).to have_http_status(400)
end
- it "should return a 422 error when access level is not known" do
+ it "returns a 422 error when access level is not known" do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: 1234
expect(response).to have_http_status(422)
end
@@ -94,24 +94,24 @@ describe API::API, api: true do
describe "PUT /projects/:id/members/:user_id" do
before { project_member2 }
- it "should update project team member" do
+ it "updates project team member" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: ProjectMember::MASTER
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user3.username)
expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end
- it "should return a 404 error if user_id is not found" do
+ it "returns a 404 error if user_id is not found" do
put api("/projects/#{project.id}/members/1234", user), access_level: ProjectMember::MASTER
expect(response).to have_http_status(404)
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
put api("/projects/#{project.id}/members/#{user3.id}", user)
expect(response).to have_http_status(400)
end
- it "should return a 422 error when access level is not known" do
+ it "returns a 422 error when access level is not known" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: 123
expect(response).to have_http_status(422)
end
@@ -123,13 +123,13 @@ describe API::API, api: true do
project_member2
end
- it "should remove user from project team" do
+ it "removes user from project team" do
expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
end.to change { ProjectMember.count }.by(-1)
end
- it "should return 200 if team member is not part of a project" do
+ it "returns 200 if team member is not part of a project" do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
@@ -137,13 +137,13 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return 200 if team member already removed" do
+ it "returns 200 if team member already removed" do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect(response).to have_http_status(200)
end
- it "should return 200 OK when the user was not member" do
+ it "returns 200 OK when the user was not member" do
expect do
delete api("/projects/#{project.id}/members/1000000", user)
end.to change { ProjectMember.count }.by(0)
diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb
index 4ebde201941..42757ff21b0 100644
--- a/spec/requests/api/project_snippets_spec.rb
+++ b/spec/requests/api/project_snippets_spec.rb
@@ -17,7 +17,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:project_id/snippets/' do
- it 'all snippets available to team member' do
+ it 'returns all snippets available to team member' do
project = create(:project, :public)
user = create(:user)
project.team << [user, :developer]
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 8c6a7e6529d..4742b3d0e37 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -43,14 +43,14 @@ describe API::API, api: true do
before { project }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api('/projects')
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return an array of projects' do
+ it 'returns an array of projects' do
get api('/projects', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -58,21 +58,21 @@ describe API::API, api: true do
expect(json_response.first['owner']['username']).to eq(user.username)
end
- it 'should include the project labels as the tag_list' do
+ it 'includes the project labels as the tag_list' do
get api('/projects', user)
expect(response.status).to eq 200
expect(json_response).to be_an Array
expect(json_response.first.keys).to include('tag_list')
end
- it 'should include open_issues_count' do
+ it 'includes open_issues_count' do
get api('/projects', user)
expect(response.status).to eq 200
expect(json_response).to be_an Array
expect(json_response.first.keys).to include('open_issues_count')
end
- it 'should not include open_issues_count' do
+ it 'does not include open_issues_count' do
project.update_attributes( { issues_enabled: false } )
get api('/projects', user)
@@ -94,7 +94,7 @@ describe API::API, api: true do
end
context 'and using search' do
- it 'should return searched project' do
+ it 'returns searched project' do
get api('/projects', user), { search: project.name }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -103,21 +103,21 @@ describe API::API, api: true do
end
context 'and using the visibility filter' do
- it 'should filter based on private visibility param' do
+ it 'filters based on private visibility param' do
get api('/projects', user), { visibility: 'private' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PRIVATE).count)
end
- it 'should filter based on internal visibility param' do
+ it 'filters based on internal visibility param' do
get api('/projects', user), { visibility: 'internal' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::INTERNAL).count)
end
- it 'should filter based on public visibility param' do
+ it 'filters based on public visibility param' do
get api('/projects', user), { visibility: 'public' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -131,7 +131,7 @@ describe API::API, api: true do
project3
end
- it 'should return the correct order when sorted by id' do
+ it 'returns the correct order when sorted by id' do
get api('/projects', user), { order_by: 'id', sort: 'desc' }
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -145,21 +145,21 @@ describe API::API, api: true do
before { project }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api('/projects/all')
expect(response).to have_http_status(401)
end
end
context 'when authenticated as regular user' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api('/projects/all', user)
expect(response).to have_http_status(403)
end
end
context 'when authenticated as admin' do
- it 'should return an array of all projects' do
+ it 'returns an array of all projects' do
get api('/projects/all', admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -183,7 +183,7 @@ describe API::API, api: true do
user3.update_attributes(starred_projects: [project, project2, project3, public_project])
end
- it 'should return the starred projects viewable by the user' do
+ it 'returns the starred projects viewable by the user' do
get api('/projects/starred', user3)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -193,7 +193,7 @@ describe API::API, api: true do
describe 'POST /projects' do
context 'maximum number of projects reached' do
- it 'should not create new project and respond with 403' do
+ it 'does not create new project and respond with 403' do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0)
expect { post api('/projects', user2), name: 'foo' }.
to change {Project.count}.by(0)
@@ -201,24 +201,24 @@ describe API::API, api: true do
end
end
- it 'should create new project without path and return 201' do
+ it 'creates new project without path and return 201' do
expect { post api('/projects', user), name: 'foo' }.
to change { Project.count }.by(1)
expect(response).to have_http_status(201)
end
- it 'should create last project before reaching project limit' do
+ it 'creates last project before reaching project limit' do
allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1)
post api('/projects', user2), name: 'foo'
expect(response).to have_http_status(201)
end
- it 'should not create new project without name and return 400' do
+ it 'does not create new project without name and return 400' do
expect { post api('/projects', user) }.not_to change { Project.count }
expect(response).to have_http_status(400)
end
- it "should assign attributes to project" do
+ it "assigns attributes to project" do
project = attributes_for(:project, {
path: 'camelCasePath',
description: FFaker::Lorem.sentence,
@@ -234,42 +234,42 @@ describe API::API, api: true do
end
end
- it 'should set a project as public' do
+ it 'sets a project as public' do
project = attributes_for(:project, :public)
post api('/projects', user), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as public using :public' do
+ it 'sets a project as public using :public' do
project = attributes_for(:project, { public: true })
post api('/projects', user), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as internal' do
+ it 'sets a project as internal' do
project = attributes_for(:project, :internal)
post api('/projects', user), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as internal overriding :public' do
+ it 'sets a project as internal overriding :public' do
project = attributes_for(:project, :internal, { public: true })
post api('/projects', user), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as private' do
+ it 'sets a project as private' do
project = attributes_for(:project, :private)
post api('/projects', user), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
- it 'should set a project as private using :public' do
+ it 'sets a project as private using :public' do
project = attributes_for(:project, { public: false })
post api('/projects', user), project
expect(json_response['public']).to be_falsey
@@ -282,7 +282,7 @@ describe API::API, api: true do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- it 'should not allow a non-admin to use a restricted visibility level' do
+ it 'does not allow a non-admin to use a restricted visibility level' do
post api('/projects', user), @project
expect(response).to have_http_status(400)
@@ -291,7 +291,7 @@ describe API::API, api: true do
)
end
- it 'should allow an admin to override restricted visibility settings' do
+ it 'allows an admin to override restricted visibility settings' do
post api('/projects', admin), @project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to(
@@ -310,7 +310,7 @@ describe API::API, api: true do
expect(response).to have_http_status(201)
end
- it 'should respond with 400 on failure and not project' do
+ it 'responds with 400 on failure and not project' do
expect { post api("/projects/user/#{user.id}", admin) }.
not_to change { Project.count }
@@ -327,7 +327,7 @@ describe API::API, api: true do
])
end
- it 'should assign attributes to project' do
+ it 'assigns attributes to project' do
project = attributes_for(:project, {
description: FFaker::Lorem.sentence,
issues_enabled: false,
@@ -343,42 +343,42 @@ describe API::API, api: true do
end
end
- it 'should set a project as public' do
+ it 'sets a project as public' do
project = attributes_for(:project, :public)
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as public using :public' do
+ it 'sets a project as public using :public' do
project = attributes_for(:project, { public: true })
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_truthy
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'should set a project as internal' do
+ it 'sets a project as internal' do
project = attributes_for(:project, :internal)
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as internal overriding :public' do
+ it 'sets a project as internal overriding :public' do
project = attributes_for(:project, :internal, { public: true })
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'should set a project as private' do
+ it 'sets a project as private' do
project = attributes_for(:project, :private)
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
- it 'should set a project as private using :public' do
+ it 'sets a project as private using :public' do
project = attributes_for(:project, { public: false })
post api("/projects/user/#{user.id}", admin), project
expect(json_response['public']).to be_falsey
@@ -446,25 +446,25 @@ describe API::API, api: true do
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
end
- it 'should return a project by path name' do
+ it 'returns a project by path name' do
get api("/projects/#{project.id}", user)
expect(response).to have_http_status(200)
expect(json_response['name']).to eq(project.name)
end
- it 'should return a 404 error if not found' do
+ it 'returns a 404 error if not found' do
get api('/projects/42', user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
end
- it 'should return a 404 error if user is not a member' do
+ it 'returns a 404 error if user is not a member' do
other_user = create(:user)
get api("/projects/#{project.id}", other_user)
expect(response).to have_http_status(404)
end
- it 'should handle users with dots' do
+ it 'handles users with dots' do
dot_user = create(:user, username: 'dot.user')
project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace)
@@ -504,7 +504,7 @@ describe API::API, api: true do
before { project2.group.add_owner(user) }
- it 'should set the owner and return 200' do
+ it 'sets the owner and return 200' do
get api("/projects/#{project2.id}", user)
expect(response).to have_http_status(200)
@@ -545,13 +545,13 @@ describe API::API, api: true do
end
end
- it 'should return a 404 error if not found' do
+ it 'returns a 404 error if not found' do
get api('/projects/42/events', user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Project Not Found')
end
- it 'should return a 404 error if user is not a member' do
+ it 'returns a 404 error if user is not a member' do
other_user = create(:user)
get api("/projects/#{project.id}/events", other_user)
expect(response).to have_http_status(404)
@@ -561,7 +561,7 @@ describe API::API, api: true do
describe 'GET /projects/:id/snippets' do
before { snippet }
- it 'should return an array of project snippets' do
+ it 'returns an array of project snippets' do
get api("/projects/#{project.id}/snippets", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -570,20 +570,20 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/snippets/:snippet_id' do
- it 'should return a project snippet' do
+ it 'returns a project snippet' do
get api("/projects/#{project.id}/snippets/#{snippet.id}", user)
expect(response).to have_http_status(200)
expect(json_response['title']).to eq(snippet.title)
end
- it 'should return a 404 error if snippet id not found' do
+ it 'returns a 404 error if snippet id not found' do
get api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_http_status(404)
end
end
describe 'POST /projects/:id/snippets' do
- it 'should create a new project snippet' do
+ it 'creates a new project snippet' do
post api("/projects/#{project.id}/snippets", user),
title: 'api test', file_name: 'sample.rb', code: 'test',
visibility_level: '0'
@@ -591,14 +591,14 @@ describe API::API, api: true do
expect(json_response['title']).to eq('api test')
end
- it 'should return a 400 error if invalid snippet is given' do
+ it 'returns a 400 error if invalid snippet is given' do
post api("/projects/#{project.id}/snippets", user)
expect(status).to eq(400)
end
end
describe 'PUT /projects/:id/snippets/:snippet_id' do
- it 'should update an existing project snippet' do
+ it 'updates an existing project snippet' do
put api("/projects/#{project.id}/snippets/#{snippet.id}", user),
code: 'updated code'
expect(response).to have_http_status(200)
@@ -606,7 +606,7 @@ describe API::API, api: true do
expect(snippet.reload.content).to eq('updated code')
end
- it 'should update an existing project snippet with new title' do
+ it 'updates an existing project snippet with new title' do
put api("/projects/#{project.id}/snippets/#{snippet.id}", user),
title: 'other api test'
expect(response).to have_http_status(200)
@@ -617,103 +617,31 @@ describe API::API, api: true do
describe 'DELETE /projects/:id/snippets/:snippet_id' do
before { snippet }
- it 'should delete existing project snippet' do
+ it 'deletes existing project snippet' do
expect do
delete api("/projects/#{project.id}/snippets/#{snippet.id}", user)
end.to change { Snippet.count }.by(-1)
expect(response).to have_http_status(200)
end
- it 'should return 404 when deleting unknown snippet id' do
+ it 'returns 404 when deleting unknown snippet id' do
delete api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_http_status(404)
end
end
describe 'GET /projects/:id/snippets/:snippet_id/raw' do
- it 'should get a raw project snippet' do
+ it 'gets a raw project snippet' do
get api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user)
expect(response).to have_http_status(200)
end
- it 'should return a 404 error if raw project snippet not found' do
+ it 'returns a 404 error if raw project snippet not found' do
get api("/projects/#{project.id}/snippets/5555/raw", user)
expect(response).to have_http_status(404)
end
end
- describe :deploy_keys do
- let(:deploy_keys_project) { create(:deploy_keys_project, project: project) }
- let(:deploy_key) { deploy_keys_project.deploy_key }
-
- describe 'GET /projects/:id/deploy_keys' do
- before { deploy_key }
-
- it 'should return array of ssh keys' do
- get api("/projects/#{project.id}/deploy_keys", user)
- expect(response).to have_http_status(200)
- expect(json_response).to be_an Array
- expect(json_response.first['title']).to eq(deploy_key.title)
- end
- end
-
- describe 'GET /projects/:id/deploy_keys/:key_id' do
- it 'should return a single key' do
- get api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user)
- expect(response).to have_http_status(200)
- expect(json_response['title']).to eq(deploy_key.title)
- end
-
- it 'should return 404 Not Found with invalid ID' do
- get api("/projects/#{project.id}/deploy_keys/404", user)
- expect(response).to have_http_status(404)
- end
- end
-
- describe 'POST /projects/:id/deploy_keys' do
- it 'should not create an invalid ssh key' do
- post api("/projects/#{project.id}/deploy_keys", user), { title: 'invalid key' }
- expect(response).to have_http_status(400)
- expect(json_response['message']['key']).to eq([
- 'can\'t be blank',
- 'is too short (minimum is 0 characters)',
- 'is invalid'
- ])
- end
-
- it 'should not create a key without title' do
- post api("/projects/#{project.id}/deploy_keys", user), key: 'some key'
- expect(response).to have_http_status(400)
- expect(json_response['message']['title']).to eq([
- 'can\'t be blank',
- 'is too short (minimum is 0 characters)'
- ])
- end
-
- it 'should create new ssh key' do
- key_attrs = attributes_for :key
- expect do
- post api("/projects/#{project.id}/deploy_keys", user), key_attrs
- end.to change{ project.deploy_keys.count }.by(1)
- end
- end
-
- describe 'DELETE /projects/:id/deploy_keys/:key_id' do
- before { deploy_key }
-
- it 'should delete existing key' do
- expect do
- delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user)
- end.to change{ project.deploy_keys.count }.by(-1)
- end
-
- it 'should return 404 Not Found with invalid ID' do
- delete api("/projects/#{project.id}/deploy_keys/404", user)
- expect(response).to have_http_status(404)
- end
- end
- end
-
describe :fork_admin do
let(:project_fork_target) { create(:project) }
let(:project_fork_source) { create(:project, :public) }
@@ -721,12 +649,12 @@ describe API::API, api: true do
describe 'POST /projects/:id/fork/:forked_from_id' do
let(:new_project_fork_source) { create(:project, :public) }
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
expect(response).to have_http_status(403)
end
- it 'should allow project to be forked from an existing project' do
+ it 'allows project to be forked from an existing project' do
expect(project_fork_target.forked?).not_to be_truthy
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
expect(response).to have_http_status(201)
@@ -736,12 +664,12 @@ describe API::API, api: true do
expect(project_fork_target.forked?).to be_truthy
end
- it 'should fail if forked_from project which does not exist' do
+ it 'fails if forked_from project which does not exist' do
post api("/projects/#{project_fork_target.id}/fork/9999", admin)
expect(response).to have_http_status(404)
end
- it 'should fail with 409 if already forked' do
+ it 'fails with 409 if already forked' do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
project_fork_target.reload
expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id)
@@ -754,7 +682,7 @@ describe API::API, api: true do
end
describe 'DELETE /projects/:id/fork' do
- it "shouldn't be visible to users outside group" do
+ it "is not visible to users outside group" do
delete api("/projects/#{project_fork_target.id}/fork", user)
expect(response).to have_http_status(404)
end
@@ -767,12 +695,12 @@ describe API::API, api: true do
project_fork_target.group.add_developer user2
end
- it 'should be forbidden to non-owner users' do
+ it 'is forbidden to non-owner users' do
delete api("/projects/#{project_fork_target.id}/fork", user2)
expect(response).to have_http_status(403)
end
- it 'should make forked project unforked' do
+ it 'makes forked project unforked' do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
project_fork_target.reload
expect(project_fork_target.forked_from_project).not_to be_nil
@@ -784,7 +712,7 @@ describe API::API, api: true do
expect(project_fork_target.forked?).not_to be_truthy
end
- it 'should be idempotent if not forked' do
+ it 'is idempotent if not forked' do
expect(project_fork_target.forked_from_project).to be_nil
delete api("/projects/#{project_fork_target.id}/fork", admin)
expect(response).to have_http_status(200)
@@ -797,7 +725,7 @@ describe API::API, api: true do
describe "POST /projects/:id/share" do
let(:group) { create(:group) }
- it "should share project with group" do
+ it "shares project with group" do
expect do
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER
end.to change { ProjectGroupLink.count }.by(1)
@@ -807,23 +735,23 @@ describe API::API, api: true do
expect(json_response['group_access']).to eq Gitlab::Access::DEVELOPER
end
- it "should return a 400 error when group id is not given" do
+ it "returns a 400 error when group id is not given" do
post api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER
expect(response.status).to eq 400
end
- it "should return a 400 error when access level is not given" do
+ it "returns a 400 error when access level is not given" do
post api("/projects/#{project.id}/share", user), group_id: group.id
expect(response.status).to eq 400
end
- it "should return a 400 error when sharing is disabled" do
+ it "returns a 400 error when sharing is disabled" do
project.namespace.update(share_with_group_lock: true)
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER
expect(response.status).to eq 400
end
- it "should return a 409 error when wrong params passed" do
+ it "returns a 409 error when wrong params passed" do
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234
expect(response.status).to eq 409
expect(json_response['message']).to eq 'Group access is not included in the list'
@@ -843,14 +771,14 @@ describe API::API, api: true do
let!(:unfound_public) { create(:empty_project, :public, name: 'unfound public') }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/projects/search/#{query}")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return an array of projects' do
+ it 'returns an array of projects' do
get api("/projects/search/#{query}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -860,7 +788,7 @@ describe API::API, api: true do
end
context 'when authenticated as a different user' do
- it 'should return matching public projects' do
+ it 'returns matching public projects' do
get api("/projects/search/#{query}", user2)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -881,7 +809,7 @@ describe API::API, api: true do
before { project_member2 }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
project_param = { name: 'bar' }
put api("/projects/#{project.id}"), project_param
expect(response).to have_http_status(401)
@@ -889,7 +817,7 @@ describe API::API, api: true do
end
context 'when authenticated as project owner' do
- it 'should update name' do
+ it 'updates name' do
project_param = { name: 'bar' }
put api("/projects/#{project.id}", user), project_param
expect(response).to have_http_status(200)
@@ -898,7 +826,7 @@ describe API::API, api: true do
end
end
- it 'should update visibility_level' do
+ it 'updates visibility_level' do
project_param = { visibility_level: 20 }
put api("/projects/#{project3.id}", user), project_param
expect(response).to have_http_status(200)
@@ -907,7 +835,7 @@ describe API::API, api: true do
end
end
- it 'should update visibility_level from public to private' do
+ it 'updates visibility_level from public to private' do
project3.update_attributes({ visibility_level: Gitlab::VisibilityLevel::PUBLIC })
project_param = { public: false }
@@ -919,14 +847,14 @@ describe API::API, api: true do
expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
- it 'should not update name to existing name' do
+ it 'does not update name to existing name' do
project_param = { name: project3.name }
put api("/projects/#{project.id}", user), project_param
expect(response).to have_http_status(400)
expect(json_response['message']['name']).to eq(['has already been taken'])
end
- it 'should update path & name to existing path & name in different namespace' do
+ it 'updates path & name to existing path & name in different namespace' do
project_param = { path: project4.path, name: project4.name }
put api("/projects/#{project3.id}", user), project_param
expect(response).to have_http_status(200)
@@ -937,7 +865,7 @@ describe API::API, api: true do
end
context 'when authenticated as project master' do
- it 'should update path' do
+ it 'updates path' do
project_param = { path: 'bar' }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(200)
@@ -946,7 +874,7 @@ describe API::API, api: true do
end
end
- it 'should update other attributes' do
+ it 'updates other attributes' do
project_param = { issues_enabled: true,
wiki_enabled: true,
snippets_enabled: true,
@@ -960,20 +888,20 @@ describe API::API, api: true do
end
end
- it 'should not update path to existing path' do
+ it 'does not update path to existing path' do
project_param = { path: project.path }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(400)
expect(json_response['message']['path']).to eq(['has already been taken'])
end
- it 'should not update name' do
+ it 'does not update name' do
project_param = { name: 'bar' }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(403)
end
- it 'should not update visibility_level' do
+ it 'does not update visibility_level' do
project_param = { visibility_level: 20 }
put api("/projects/#{project3.id}", user4), project_param
expect(response).to have_http_status(403)
@@ -981,7 +909,7 @@ describe API::API, api: true do
end
context 'when authenticated as project developer' do
- it 'should not update other attributes' do
+ it 'does not update other attributes' do
project_param = { path: 'bar',
issues_enabled: true,
wiki_enabled: true,
@@ -1116,36 +1044,36 @@ describe API::API, api: true do
describe 'DELETE /projects/:id' do
context 'when authenticated as user' do
- it 'should remove project' do
+ it 'removes project' do
delete api("/projects/#{project.id}", user)
expect(response).to have_http_status(200)
end
- it 'should not remove a project if not an owner' do
+ it 'does not remove a project if not an owner' do
user3 = create(:user)
project.team << [user3, :developer]
delete api("/projects/#{project.id}", user3)
expect(response).to have_http_status(403)
end
- it 'should not remove a non existing project' do
+ it 'does not remove a non existing project' do
delete api('/projects/1328', user)
expect(response).to have_http_status(404)
end
- it 'should not remove a project not attached to user' do
+ it 'does not remove a project not attached to user' do
delete api("/projects/#{project.id}", user2)
expect(response).to have_http_status(404)
end
end
context 'when authenticated as admin' do
- it 'should remove any existing project' do
+ it 'removes any existing project' do
delete api("/projects/#{project.id}", admin)
expect(response).to have_http_status(200)
end
- it 'should not remove a non existing project' do
+ it 'does not remove a non existing project' do
delete api('/projects/1328', admin)
expect(response).to have_http_status(404)
end
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index 5890e9c9d3d..80a856a6e90 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -16,7 +16,7 @@ describe API::API, api: true do
context "authorized user" do
before { project.team << [user2, :reporter] }
- it "should return project commits" do
+ it "returns project commits" do
get api("/projects/#{project.id}/repository/tree", user)
expect(response).to have_http_status(200)
@@ -26,7 +26,7 @@ describe API::API, api: true do
expect(json_response.first['mode']).to eq('040000')
end
- it 'should return a 404 for unknown ref' do
+ it 'returns a 404 for unknown ref' do
get api("/projects/#{project.id}/repository/tree?ref_name=foo", user)
expect(response).to have_http_status(404)
@@ -36,7 +36,7 @@ describe API::API, api: true do
end
context "unauthorized user" do
- it "should not return project commits" do
+ it "does not return project commits" do
get api("/projects/#{project.id}/repository/tree")
expect(response).to have_http_status(401)
end
@@ -44,41 +44,41 @@ describe API::API, api: true do
end
describe "GET /projects/:id/repository/blobs/:sha" do
- it "should get the raw file contents" do
+ it "gets the raw file contents" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.md", user)
expect(response).to have_http_status(200)
end
- it "should return 404 for invalid branch_name" do
+ it "returns 404 for invalid branch_name" do
get api("/projects/#{project.id}/repository/blobs/invalid_branch_name?filepath=README.md", user)
expect(response).to have_http_status(404)
end
- it "should return 404 for invalid file" do
+ it "returns 404 for invalid file" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.invalid", user)
expect(response).to have_http_status(404)
end
- it "should return a 400 error if filepath is missing" do
+ it "returns a 400 error if filepath is missing" do
get api("/projects/#{project.id}/repository/blobs/master", user)
expect(response).to have_http_status(400)
end
end
describe "GET /projects/:id/repository/commits/:sha/blob" do
- it "should get the raw file contents" do
+ it "gets the raw file contents" do
get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user)
expect(response).to have_http_status(200)
end
end
describe "GET /projects/:id/repository/raw_blobs/:sha" do
- it "should get the raw file contents" do
+ it "gets the raw file contents" do
get api("/projects/#{project.id}/repository/raw_blobs/#{sample_blob.oid}", user)
expect(response).to have_http_status(200)
end
- it 'should return a 404 for unknown blob' do
+ it 'returns a 404 for unknown blob' do
get api("/projects/#{project.id}/repository/raw_blobs/123456", user)
expect(response).to have_http_status(404)
@@ -88,7 +88,7 @@ describe API::API, api: true do
end
describe "GET /projects/:id/repository/archive(.:format)?:sha" do
- it "should get the archive" do
+ it "gets the archive" do
get api("/projects/#{project.id}/repository/archive", user)
repo_name = project.repository.name.gsub("\.git", "")
expect(response).to have_http_status(200)
@@ -97,7 +97,7 @@ describe API::API, api: true do
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.gz/)
end
- it "should get the archive.zip" do
+ it "gets the archive.zip" do
get api("/projects/#{project.id}/repository/archive.zip", user)
repo_name = project.repository.name.gsub("\.git", "")
expect(response).to have_http_status(200)
@@ -106,7 +106,7 @@ describe API::API, api: true do
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.zip/)
end
- it "should get the archive.tar.bz2" do
+ it "gets the archive.tar.bz2" do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user)
repo_name = project.repository.name.gsub("\.git", "")
expect(response).to have_http_status(200)
@@ -115,28 +115,28 @@ describe API::API, api: true do
expect(params['ArchivePath']).to match(/#{repo_name}\-[^\.]+\.tar.bz2/)
end
- it "should return 404 for invalid sha" do
+ it "returns 404 for invalid sha" do
get api("/projects/#{project.id}/repository/archive/?sha=xxx", user)
expect(response).to have_http_status(404)
end
end
describe 'GET /projects/:id/repository/compare' do
- it "should compare branches" do
+ it "compares branches" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'feature'
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present
end
- it "should compare tags" do
+ it "compares tags" do
get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.0', to: 'v1.1.0'
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present
end
- it "should compare commits" do
+ it "compares commits" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.id, to: sample_commit.parent_id
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_empty
@@ -144,14 +144,14 @@ describe API::API, api: true do
expect(json_response['compare_same_ref']).to be_falsey
end
- it "should compare commits in reverse order" do
+ it "compares commits in reverse order" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.parent_id, to: sample_commit.id
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_present
expect(json_response['diffs']).to be_present
end
- it "should compare same refs" do
+ it "compares same refs" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'master'
expect(response).to have_http_status(200)
expect(json_response['commits']).to be_empty
@@ -161,7 +161,7 @@ describe API::API, api: true do
end
describe 'GET /projects/:id/repository/contributors' do
- it 'should return valid data' do
+ it 'returns valid data' do
get api("/projects/#{project.id}/repository/contributors", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index 00a3c917b6a..f46f016135e 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -35,7 +35,7 @@ describe API::Runners, api: true do
describe 'GET /runners' do
context 'authorized user' do
- it 'should return user available runners' do
+ it 'returns user available runners' do
get api('/runners', user)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -44,7 +44,7 @@ describe API::Runners, api: true do
expect(shared).to be_falsey
end
- it 'should filter runners by scope' do
+ it 'filters runners by scope' do
get api('/runners?scope=active', user)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -53,14 +53,14 @@ describe API::Runners, api: true do
expect(shared).to be_falsey
end
- it 'should avoid filtering if scope is invalid' do
+ it 'avoids filtering if scope is invalid' do
get api('/runners?scope=unknown', user)
expect(response).to have_http_status(400)
end
end
context 'unauthorized user' do
- it 'should not return runners' do
+ it 'does not return runners' do
get api('/runners')
expect(response).to have_http_status(401)
@@ -71,7 +71,7 @@ describe API::Runners, api: true do
describe 'GET /runners/all' do
context 'authorized user' do
context 'with admin privileges' do
- it 'should return all runners' do
+ it 'returns all runners' do
get api('/runners/all', admin)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -82,14 +82,14 @@ describe API::Runners, api: true do
end
context 'without admin privileges' do
- it 'should not return runners list' do
+ it 'does not return runners list' do
get api('/runners/all', user)
expect(response).to have_http_status(403)
end
end
- it 'should filter runners by scope' do
+ it 'filters runners by scope' do
get api('/runners/all?scope=specific', admin)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -98,14 +98,14 @@ describe API::Runners, api: true do
expect(shared).to be_falsey
end
- it 'should avoid filtering if scope is invalid' do
+ it 'avoids filtering if scope is invalid' do
get api('/runners?scope=unknown', admin)
expect(response).to have_http_status(400)
end
end
context 'unauthorized user' do
- it 'should not return runners' do
+ it 'does not return runners' do
get api('/runners')
expect(response).to have_http_status(401)
@@ -116,7 +116,7 @@ describe API::Runners, api: true do
describe 'GET /runners/:id' do
context 'admin user' do
context 'when runner is shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{shared_runner.id}", admin)
expect(response).to have_http_status(200)
@@ -125,7 +125,7 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{specific_runner.id}", admin)
expect(response).to have_http_status(200)
@@ -133,7 +133,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 if runner does not exists' do
+ it 'returns 404 if runner does not exists' do
get api('/runners/9999', admin)
expect(response).to have_http_status(404)
@@ -142,7 +142,7 @@ describe API::Runners, api: true do
context "runner project's administrative user" do
context 'when runner is not shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{specific_runner.id}", user)
expect(response).to have_http_status(200)
@@ -151,7 +151,7 @@ describe API::Runners, api: true do
end
context 'when runner is shared' do
- it "should return runner's details" do
+ it "returns runner's details" do
get api("/runners/#{shared_runner.id}", user)
expect(response).to have_http_status(200)
@@ -161,7 +161,7 @@ describe API::Runners, api: true do
end
context 'other authorized user' do
- it "should not return runner's details" do
+ it "does not return runner's details" do
get api("/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
@@ -169,7 +169,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it "should not return runner's details" do
+ it "does not return runner's details" do
get api("/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
@@ -180,7 +180,7 @@ describe API::Runners, api: true do
describe 'PUT /runners/:id' do
context 'admin user' do
context 'when runner is shared' do
- it 'should update runner' do
+ it 'updates runner' do
description = shared_runner.description
active = shared_runner.active
@@ -201,7 +201,7 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it 'should update runner' do
+ it 'updates runner' do
description = specific_runner.description
update_runner(specific_runner.id, admin, description: 'test')
specific_runner.reload
@@ -212,7 +212,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 if runner does not exists' do
+ it 'returns 404 if runner does not exists' do
update_runner(9999, admin, description: 'test')
expect(response).to have_http_status(404)
@@ -225,7 +225,7 @@ describe API::Runners, api: true do
context 'authorized user' do
context 'when runner is shared' do
- it 'should not update runner' do
+ it 'does not update runner' do
put api("/runners/#{shared_runner.id}", user)
expect(response).to have_http_status(403)
@@ -233,13 +233,13 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it 'should not update runner without access to it' do
+ it 'does not update runner without access to it' do
put api("/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
end
- it 'should update runner with access to it' do
+ it 'updates runner with access to it' do
description = specific_runner.description
put api("/runners/#{specific_runner.id}", admin), description: 'test'
specific_runner.reload
@@ -252,7 +252,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it 'should not delete runner' do
+ it 'does not delete runner' do
put api("/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
@@ -263,7 +263,7 @@ describe API::Runners, api: true do
describe 'DELETE /runners/:id' do
context 'admin user' do
context 'when runner is shared' do
- it 'should delete runner' do
+ it 'deletes runner' do
expect do
delete api("/runners/#{shared_runner.id}", admin)
end.to change{ Ci::Runner.shared.count }.by(-1)
@@ -272,14 +272,14 @@ describe API::Runners, api: true do
end
context 'when runner is not shared' do
- it 'should delete unused runner' do
+ it 'deletes unused runner' do
expect do
delete api("/runners/#{unused_specific_runner.id}", admin)
end.to change{ Ci::Runner.specific.count }.by(-1)
expect(response).to have_http_status(200)
end
- it 'should delete used runner' do
+ it 'deletes used runner' do
expect do
delete api("/runners/#{specific_runner.id}", admin)
end.to change{ Ci::Runner.specific.count }.by(-1)
@@ -287,7 +287,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 if runner does not exists' do
+ it 'returns 404 if runner does not exists' do
delete api('/runners/9999', admin)
expect(response).to have_http_status(404)
@@ -296,24 +296,24 @@ describe API::Runners, api: true do
context 'authorized user' do
context 'when runner is shared' do
- it 'should not delete runner' do
+ it 'does not delete runner' do
delete api("/runners/#{shared_runner.id}", user)
expect(response).to have_http_status(403)
end
end
context 'when runner is not shared' do
- it 'should not delete runner without access to it' do
+ it 'does not delete runner without access to it' do
delete api("/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
end
- it 'should not delete runner with more than one associated project' do
+ it 'does not delete runner with more than one associated project' do
delete api("/runners/#{two_projects_runner.id}", user)
expect(response).to have_http_status(403)
end
- it 'should delete runner for one owned project' do
+ it 'deletes runner for one owned project' do
expect do
delete api("/runners/#{specific_runner.id}", user)
end.to change{ Ci::Runner.specific.count }.by(-1)
@@ -323,7 +323,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it 'should not delete runner' do
+ it 'does not delete runner' do
delete api("/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
@@ -333,7 +333,7 @@ describe API::Runners, api: true do
describe 'GET /projects/:id/runners' do
context 'authorized user with master privileges' do
- it "should return project's runners" do
+ it "returns project's runners" do
get api("/projects/#{project.id}/runners", user)
shared = json_response.any?{ |r| r['is_shared'] }
@@ -344,7 +344,7 @@ describe API::Runners, api: true do
end
context 'authorized user without master privileges' do
- it "should not return project's runners" do
+ it "does not return project's runners" do
get api("/projects/#{project.id}/runners", user2)
expect(response).to have_http_status(403)
@@ -352,7 +352,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it "should not return project's runners" do
+ it "does not return project's runners" do
get api("/projects/#{project.id}/runners")
expect(response).to have_http_status(401)
@@ -368,21 +368,21 @@ describe API::Runners, api: true do
end
end
- it 'should enable specific runner' do
+ it 'enables specific runner' do
expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id
end.to change{ project.runners.count }.by(+1)
expect(response).to have_http_status(201)
end
- it 'should avoid changes when enabling already enabled runner' do
+ it 'avoids changes when enabling already enabled runner' do
expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id
end.to change{ project.runners.count }.by(0)
expect(response).to have_http_status(409)
end
- it 'should not enable locked runner' do
+ it 'does not enable locked runner' do
specific_runner2.update(locked: true)
expect do
@@ -392,14 +392,14 @@ describe API::Runners, api: true do
expect(response).to have_http_status(403)
end
- it 'should not enable shared runner' do
+ it 'does not enable shared runner' do
post api("/projects/#{project.id}/runners", user), runner_id: shared_runner.id
expect(response).to have_http_status(403)
end
context 'user is admin' do
- it 'should enable any specific runner' do
+ it 'enables any specific runner' do
expect do
post api("/projects/#{project.id}/runners", admin), runner_id: unused_specific_runner.id
end.to change{ project.runners.count }.by(+1)
@@ -408,14 +408,14 @@ describe API::Runners, api: true do
end
context 'user is not admin' do
- it 'should not enable runner without access to' do
+ it 'does not enable runner without access to' do
post api("/projects/#{project.id}/runners", user), runner_id: unused_specific_runner.id
expect(response).to have_http_status(403)
end
end
- it 'should raise an error when no runner_id param is provided' do
+ it 'raises an error when no runner_id param is provided' do
post api("/projects/#{project.id}/runners", admin)
expect(response).to have_http_status(400)
@@ -423,7 +423,7 @@ describe API::Runners, api: true do
end
context 'authorized user without permissions' do
- it 'should not enable runner' do
+ it 'does not enable runner' do
post api("/projects/#{project.id}/runners", user2)
expect(response).to have_http_status(403)
@@ -431,7 +431,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it 'should not enable runner' do
+ it 'does not enable runner' do
post api("/projects/#{project.id}/runners")
expect(response).to have_http_status(401)
@@ -442,7 +442,7 @@ describe API::Runners, api: true do
describe 'DELETE /projects/:id/runners/:runner_id' do
context 'authorized user' do
context 'when runner have more than one associated projects' do
- it "should disable project's runner" do
+ it "disables project's runner" do
expect do
delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user)
end.to change{ project.runners.count }.by(-1)
@@ -451,7 +451,7 @@ describe API::Runners, api: true do
end
context 'when runner have one associated projects' do
- it "should not disable project's runner" do
+ it "does not disable project's runner" do
expect do
delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user)
end.to change{ project.runners.count }.by(0)
@@ -459,7 +459,7 @@ describe API::Runners, api: true do
end
end
- it 'should return 404 is runner is not found' do
+ it 'returns 404 is runner is not found' do
delete api("/projects/#{project.id}/runners/9999", user)
expect(response).to have_http_status(404)
@@ -467,7 +467,7 @@ describe API::Runners, api: true do
end
context 'authorized user without permissions' do
- it "should not disable project's runner" do
+ it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user2)
expect(response).to have_http_status(403)
@@ -475,7 +475,7 @@ describe API::Runners, api: true do
end
context 'unauthorized user' do
- it "should not disable project's runner" do
+ it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{specific_runner.id}")
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index a2446e12804..375671bca4c 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -11,13 +11,13 @@ describe API::API, api: true do
describe "PUT /projects/:id/services/#{service.dasherize}" do
include_context service
- it "should update #{service} settings" do
+ it "updates #{service} settings" do
put api("/projects/#{project.id}/services/#{dashed_service}", user), service_attrs
expect(response).to have_http_status(200)
end
- it "should return if required fields missing" do
+ it "returns if required fields missing" do
attrs = service_attrs
required_attributes = service_attrs_list.select do |attr|
@@ -32,7 +32,7 @@ describe API::API, api: true do
attrs.delete(required_attributes.sample)
expected_code = 400
end
-
+
put api("/projects/#{project.id}/services/#{dashed_service}", user), attrs
expect(response.status).to eq(expected_code)
@@ -42,7 +42,7 @@ describe API::API, api: true do
describe "DELETE /projects/:id/services/#{service.dasherize}" do
include_context service
- it "should delete #{service}" do
+ it "deletes #{service}" do
delete api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_http_status(200)
@@ -62,29 +62,29 @@ describe API::API, api: true do
service_object.save
end
- it 'should return authentication error when unauthenticated' do
+ it 'returns authentication error when unauthenticated' do
get api("/projects/#{project.id}/services/#{dashed_service}")
expect(response).to have_http_status(401)
end
-
- it "should return all properties of service #{service} when authenticated as admin" do
+
+ it "returns all properties of service #{service} when authenticated as admin" do
get api("/projects/#{project.id}/services/#{dashed_service}", admin)
-
+
expect(response).to have_http_status(200)
expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list.map)
end
- it "should return properties of service #{service} other than passwords when authenticated as project owner" do
+ it "returns properties of service #{service} other than passwords when authenticated as project owner" do
get api("/projects/#{project.id}/services/#{dashed_service}", user)
expect(response).to have_http_status(200)
expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list_without_passwords)
end
- it "should return error when authenticated but not a project owner" do
+ it "returns error when authenticated but not a project owner" do
project.team << [user2, :developer]
get api("/projects/#{project.id}/services/#{dashed_service}", user2)
-
+
expect(response).to have_http_status(403)
end
end
diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb
index c15b7ff9792..519e7ce12ad 100644
--- a/spec/requests/api/session_spec.rb
+++ b/spec/requests/api/session_spec.rb
@@ -7,7 +7,7 @@ describe API::API, api: true do
describe "POST /session" do
context "when valid password" do
- it "should return private token" do
+ it "returns private token" do
post api("/session"), email: user.email, password: '12345678'
expect(response).to have_http_status(201)
@@ -20,7 +20,7 @@ describe API::API, api: true do
end
context 'when email has case-typo and password is valid' do
- it 'should return private token' do
+ it 'returns private token' do
post api('/session'), email: user.email.upcase, password: '12345678'
expect(response.status).to eq 201
@@ -33,7 +33,7 @@ describe API::API, api: true do
end
context 'when login has case-typo and password is valid' do
- it 'should return private token' do
+ it 'returns private token' do
post api('/session'), login: user.username.upcase, password: '12345678'
expect(response.status).to eq 201
@@ -46,7 +46,7 @@ describe API::API, api: true do
end
context "when invalid password" do
- it "should return authentication error" do
+ it "returns authentication error" do
post api("/session"), email: user.email, password: '123'
expect(response).to have_http_status(401)
@@ -56,7 +56,7 @@ describe API::API, api: true do
end
context "when empty password" do
- it "should return authentication error" do
+ it "returns authentication error" do
post api("/session"), email: user.email
expect(response).to have_http_status(401)
@@ -66,7 +66,7 @@ describe API::API, api: true do
end
context "when empty name" do
- it "should return authentication error" do
+ it "returns authentication error" do
post api("/session"), password: user.password
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb
index 684c2cd8e24..54d096e8b7f 100644
--- a/spec/requests/api/settings_spec.rb
+++ b/spec/requests/api/settings_spec.rb
@@ -7,7 +7,7 @@ describe API::API, 'Settings', api: true do
let(:admin) { create(:admin) }
describe "GET /application/settings" do
- it "should return application settings" do
+ it "returns application settings" do
get api("/application/settings", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Hash
@@ -23,7 +23,7 @@ describe API::API, 'Settings', api: true do
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
- it "should update application settings" do
+ it "updates application settings" do
put api("/application/settings", admin),
default_projects_limit: 3, signin_enabled: false, repository_storage: 'custom'
expect(response).to have_http_status(200)
diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb
index cf66f261ade..1ce2658569e 100644
--- a/spec/requests/api/system_hooks_spec.rb
+++ b/spec/requests/api/system_hooks_spec.rb
@@ -11,21 +11,21 @@ describe API::API, api: true do
describe "GET /hooks" do
context "when no user" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/hooks")
expect(response).to have_http_status(401)
end
end
context "when not an admin" do
- it "should return forbidden error" do
+ it "returns forbidden error" do
get api("/hooks", user)
expect(response).to have_http_status(403)
end
end
context "when authenticated as admin" do
- it "should return an array of hooks" do
+ it "returns an array of hooks" do
get api("/hooks", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -35,18 +35,18 @@ describe API::API, api: true do
end
describe "POST /hooks" do
- it "should create new hook" do
+ it "creates new hook" do
expect do
post api("/hooks", admin), url: 'http://example.com'
end.to change { SystemHook.count }.by(1)
end
- it "should respond with 400 if url not given" do
+ it "responds with 400 if url not given" do
post api("/hooks", admin)
expect(response).to have_http_status(400)
end
- it "should not create new hook without url" do
+ it "does not create new hook without url" do
expect do
post api("/hooks", admin)
end.not_to change { SystemHook.count }
@@ -54,26 +54,26 @@ describe API::API, api: true do
end
describe "GET /hooks/:id" do
- it "should return hook by id" do
+ it "returns hook by id" do
get api("/hooks/#{hook.id}", admin)
expect(response).to have_http_status(200)
expect(json_response['event_name']).to eq('project_create')
end
- it "should return 404 on failure" do
+ it "returns 404 on failure" do
get api("/hooks/404", admin)
expect(response).to have_http_status(404)
end
end
describe "DELETE /hooks/:id" do
- it "should delete a hook" do
+ it "deletes a hook" do
expect do
delete api("/hooks/#{hook.id}", admin)
end.to change { SystemHook.count }.by(-1)
end
- it "should return success if hook id not found" do
+ it "returns success if hook id not found" do
delete api("/hooks/12345", admin)
expect(response).to have_http_status(200)
end
diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb
index fa700ab7343..d563883cd47 100644
--- a/spec/requests/api/tags_spec.rb
+++ b/spec/requests/api/tags_spec.rb
@@ -16,7 +16,7 @@ describe API::API, api: true do
let(:description) { 'Awesome release!' }
context 'without releases' do
- it "should return an array of project tags" do
+ it "returns an array of project tags" do
get api("/projects/#{project.id}/repository/tags", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -30,7 +30,7 @@ describe API::API, api: true do
release.update_attributes(description: description)
end
- it "should return an array of project tags with release info" do
+ it "returns an array of project tags with release info" do
get api("/projects/#{project.id}/repository/tags", user)
expect(response).to have_http_status(200)
@@ -61,7 +61,7 @@ describe API::API, api: true do
describe 'POST /projects/:id/repository/tags' do
context 'lightweight tags' do
- it 'should create a new tag' do
+ it 'creates a new tag' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v7.0.1',
ref: 'master'
@@ -72,7 +72,7 @@ describe API::API, api: true do
end
context 'lightweight tags with release notes' do
- it 'should create a new tag' do
+ it 'creates a new tag' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v7.0.1',
ref: 'master',
@@ -92,13 +92,13 @@ describe API::API, api: true do
end
context 'delete tag' do
- it 'should delete an existing tag' do
+ it 'deletes an existing tag' do
delete api("/projects/#{project.id}/repository/tags/#{tag_name}", user)
expect(response).to have_http_status(200)
expect(json_response['tag_name']).to eq(tag_name)
end
- it 'should raise 404 if the tag does not exist' do
+ it 'raises 404 if the tag does not exist' do
delete api("/projects/#{project.id}/repository/tags/foobar", user)
expect(response).to have_http_status(404)
end
@@ -106,7 +106,7 @@ describe API::API, api: true do
end
context 'annotated tag' do
- it 'should create a new annotated tag' do
+ it 'creates a new annotated tag' do
# Identity must be set in .gitconfig to create annotated tag.
repo_path = project.repository.path_to_repo
system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.name #{user.name}))
@@ -123,14 +123,14 @@ describe API::API, api: true do
end
end
- it 'should deny for user without push access' do
+ it 'denies for user without push access' do
post api("/projects/#{project.id}/repository/tags", user2),
tag_name: 'v1.9.0',
ref: '621491c677087aa243f165eab467bfdfbee00be1'
expect(response).to have_http_status(403)
end
- it 'should return 400 if tag name is invalid' do
+ it 'returns 400 if tag name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v 1.0.0',
ref: 'master'
@@ -138,7 +138,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Tag name invalid')
end
- it 'should return 400 if tag already exists' do
+ it 'returns 400 if tag already exists' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v8.0.0',
ref: 'master'
@@ -150,7 +150,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Tag v8.0.0 already exists')
end
- it 'should return 400 if ref name is invalid' do
+ it 'returns 400 if ref name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'mytag',
ref: 'foo'
@@ -163,7 +163,7 @@ describe API::API, api: true do
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
- it 'should create description for existing git tag' do
+ it 'creates description for existing git tag' do
post api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: description
@@ -172,7 +172,7 @@ describe API::API, api: true do
expect(json_response['description']).to eq(description)
end
- it 'should return 404 if the tag does not exist' do
+ it 'returns 404 if the tag does not exist' do
post api("/projects/#{project.id}/repository/tags/foobar/release", user),
description: description
@@ -186,7 +186,7 @@ describe API::API, api: true do
release.update_attributes(description: description)
end
- it 'should return 409 if there is already a release' do
+ it 'returns 409 if there is already a release' do
post api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: description
@@ -207,7 +207,7 @@ describe API::API, api: true do
release.update_attributes(description: description)
end
- it 'should update the release description' do
+ it 'updates the release description' do
put api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: new_description
@@ -217,7 +217,7 @@ describe API::API, api: true do
end
end
- it 'should return 404 if the tag does not exist' do
+ it 'returns 404 if the tag does not exist' do
put api("/projects/#{project.id}/repository/tags/foobar/release", user),
description: new_description
@@ -225,7 +225,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Tag does not exist')
end
- it 'should return 404 if the release does not exist' do
+ it 'returns 404 if the release does not exist' do
put api("/projects/#{project.id}/repository/tags/#{tag_name}/release", user),
description: new_description
diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb
index b0243f2f80b..82bba1ce8a4 100644
--- a/spec/requests/api/triggers_spec.rb
+++ b/spec/requests/api/triggers_spec.rb
@@ -27,17 +27,17 @@ describe API::API do
end
context 'Handles errors' do
- it 'should return bad request if token is missing' do
+ it 'returns bad request if token is missing' do
post api("/projects/#{project.id}/trigger/builds"), ref: 'master'
expect(response).to have_http_status(400)
end
- it 'should return not found if project is not found' do
+ it 'returns not found if project is not found' do
post api('/projects/0/trigger/builds'), options.merge(ref: 'master')
expect(response).to have_http_status(404)
end
- it 'should return unauthorized if token is for different project' do
+ it 'returns unauthorized if token is for different project' do
post api("/projects/#{project2.id}/trigger/builds"), options.merge(ref: 'master')
expect(response).to have_http_status(401)
end
@@ -46,7 +46,7 @@ describe API::API do
context 'Have a commit' do
let(:pipeline) { project.pipelines.last }
- it 'should create builds' do
+ it 'creates builds' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'master')
expect(response).to have_http_status(201)
pipeline.builds.reload
@@ -54,7 +54,7 @@ describe API::API do
expect(pipeline.builds.size).to eq(5)
end
- it 'should return bad request with no builds created if there\'s no commit for that ref' do
+ it 'returns bad request with no builds created if there\'s no commit for that ref' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'other-branch')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('No builds created')
@@ -65,19 +65,19 @@ describe API::API do
{ 'TRIGGER_KEY' => 'TRIGGER_VALUE' }
end
- it 'should validate variables to be a hash' do
+ it 'validates variables to be a hash' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: 'value', ref: 'master')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a hash')
end
- it 'should validate variables needs to be a map of key-valued strings' do
+ it 'validates variables needs to be a map of key-valued strings' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: { key: %w(1 2) }, ref: 'master')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a map of key-valued strings')
end
- it 'create trigger request with variables' do
+ it 'creates trigger request with variables' do
post api("/projects/#{project.id}/trigger/builds"), options.merge(variables: variables, ref: 'master')
expect(response).to have_http_status(201)
pipeline.builds.reload
@@ -89,7 +89,7 @@ describe API::API do
describe 'GET /projects/:id/triggers' do
context 'authenticated user with valid permissions' do
- it 'should return list of triggers' do
+ it 'returns list of triggers' do
get api("/projects/#{project.id}/triggers", user)
expect(response).to have_http_status(200)
@@ -99,7 +99,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers", user2)
expect(response).to have_http_status(403)
@@ -107,7 +107,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers")
expect(response).to have_http_status(401)
@@ -117,14 +117,14 @@ describe API::API do
describe 'GET /projects/:id/triggers/:token' do
context 'authenticated user with valid permissions' do
- it 'should return trigger details' do
+ it 'returns trigger details' do
get api("/projects/#{project.id}/triggers/#{trigger.token}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_a(Hash)
end
- it 'should respond with 404 Not Found if requesting non-existing trigger' do
+ it 'responds with 404 Not Found if requesting non-existing trigger' do
get api("/projects/#{project.id}/triggers/abcdef012345", user)
expect(response).to have_http_status(404)
@@ -132,7 +132,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.token}", user2)
expect(response).to have_http_status(403)
@@ -140,7 +140,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not return triggers list' do
+ it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.token}")
expect(response).to have_http_status(401)
@@ -150,7 +150,7 @@ describe API::API do
describe 'POST /projects/:id/triggers' do
context 'authenticated user with valid permissions' do
- it 'should create trigger' do
+ it 'creates trigger' do
expect do
post api("/projects/#{project.id}/triggers", user)
end.to change{project.triggers.count}.by(1)
@@ -161,7 +161,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not create trigger' do
+ it 'does not create trigger' do
post api("/projects/#{project.id}/triggers", user2)
expect(response).to have_http_status(403)
@@ -169,7 +169,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not create trigger' do
+ it 'does not create trigger' do
post api("/projects/#{project.id}/triggers")
expect(response).to have_http_status(401)
@@ -179,14 +179,14 @@ describe API::API do
describe 'DELETE /projects/:id/triggers/:token' do
context 'authenticated user with valid permissions' do
- it 'should delete trigger' do
+ it 'deletes trigger' do
expect do
delete api("/projects/#{project.id}/triggers/#{trigger.token}", user)
end.to change{project.triggers.count}.by(-1)
expect(response).to have_http_status(200)
end
- it 'should respond with 404 Not Found if requesting non-existing trigger' do
+ it 'responds with 404 Not Found if requesting non-existing trigger' do
delete api("/projects/#{project.id}/triggers/abcdef012345", user)
expect(response).to have_http_status(404)
@@ -194,7 +194,7 @@ describe API::API do
end
context 'authenticated user with invalid permissions' do
- it 'should not delete trigger' do
+ it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.token}", user2)
expect(response).to have_http_status(403)
@@ -202,7 +202,7 @@ describe API::API do
end
context 'unauthenticated user' do
- it 'should not delete trigger' do
+ it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.token}")
expect(response).to have_http_status(401)
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index e43e3e269bf..e0e041b4e15 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -13,7 +13,7 @@ describe API::API, api: true do
describe "GET /users" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/users")
expect(response).to have_http_status(401)
end
@@ -38,7 +38,7 @@ describe API::API, api: true do
end
end
- it "should return an array of users" do
+ it "returns an array of users" do
get api("/users", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -48,7 +48,7 @@ describe API::API, api: true do
end['username']).to eq(username)
end
- it "should return one user" do
+ it "returns one user" do
get api("/users?username=#{omniauth_user.username}", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -57,7 +57,7 @@ describe API::API, api: true do
end
context "when admin" do
- it "should return an array of users" do
+ it "returns an array of users" do
get api("/users", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -72,24 +72,24 @@ describe API::API, api: true do
end
describe "GET /users/:id" do
- it "should return a user by id" do
+ it "returns a user by id" do
get api("/users/#{user.id}", user)
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user.username)
end
- it "should return a 401 if unauthenticated" do
+ it "returns a 401 if unauthenticated" do
get api("/users/9998")
expect(response).to have_http_status(401)
end
- it "should return a 404 error if user id not found" do
+ it "returns a 404 error if user id not found" do
get api("/users/9999", user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should return a 404 if invalid ID" do
+ it "returns a 404 if invalid ID" do
get api("/users/1ASDF", user)
expect(response).to have_http_status(404)
end
@@ -98,13 +98,13 @@ describe API::API, api: true do
describe "POST /users" do
before{ admin }
- it "should create user" do
+ it "creates user" do
expect do
post api("/users", admin), attributes_for(:user, projects_limit: 3)
end.to change { User.count }.by(1)
end
- it "should create user with correct attributes" do
+ it "creates user with correct attributes" do
post api('/users', admin), attributes_for(:user, admin: true, can_create_group: true)
expect(response).to have_http_status(201)
user_id = json_response['id']
@@ -114,7 +114,7 @@ describe API::API, api: true do
expect(new_user.can_create_group).to eq(true)
end
- it "should create non-admin user" do
+ it "creates non-admin user" do
post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false)
expect(response).to have_http_status(201)
user_id = json_response['id']
@@ -124,7 +124,7 @@ describe API::API, api: true do
expect(new_user.can_create_group).to eq(false)
end
- it "should create non-admin users by default" do
+ it "creates non-admin users by default" do
post api('/users', admin), attributes_for(:user)
expect(response).to have_http_status(201)
user_id = json_response['id']
@@ -133,7 +133,7 @@ describe API::API, api: true do
expect(new_user.admin).to eq(false)
end
- it "should return 201 Created on success" do
+ it "returns 201 Created on success" do
post api("/users", admin), attributes_for(:user, projects_limit: 3)
expect(response).to have_http_status(201)
end
@@ -148,7 +148,7 @@ describe API::API, api: true do
expect(new_user.external).to be_falsy
end
- it 'should allow an external user to be created' do
+ it 'allows an external user to be created' do
post api("/users", admin), attributes_for(:user, external: true)
expect(response).to have_http_status(201)
@@ -158,7 +158,7 @@ describe API::API, api: true do
expect(new_user.external).to be_truthy
end
- it "should not create user with invalid email" do
+ it "does not create user with invalid email" do
post api('/users', admin),
email: 'invalid email',
password: 'password',
@@ -166,27 +166,27 @@ describe API::API, api: true do
expect(response).to have_http_status(400)
end
- it 'should return 400 error if name not given' do
+ it 'returns 400 error if name not given' do
post api('/users', admin), attributes_for(:user).except(:name)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if password not given' do
+ it 'returns 400 error if password not given' do
post api('/users', admin), attributes_for(:user).except(:password)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if email not given' do
+ it 'returns 400 error if email not given' do
post api('/users', admin), attributes_for(:user).except(:email)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if username not given' do
+ it 'returns 400 error if username not given' do
post api('/users', admin), attributes_for(:user).except(:username)
expect(response).to have_http_status(400)
end
- it 'should return 400 error if user does not validate' do
+ it 'returns 400 error if user does not validate' do
post api('/users', admin),
password: 'pass',
email: 'test@example.com',
@@ -205,7 +205,7 @@ describe API::API, api: true do
to eq([Gitlab::Regex.namespace_regex_message])
end
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
post api("/users", user), attributes_for(:user)
expect(response).to have_http_status(403)
end
@@ -219,7 +219,7 @@ describe API::API, api: true do
name: 'foo'
end
- it 'should return 409 conflict error if user with same email exists' do
+ it 'returns 409 conflict error if user with same email exists' do
expect do
post api('/users', admin),
name: 'foo',
@@ -231,7 +231,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('Email has already been taken')
end
- it 'should return 409 conflict error if same username exists' do
+ it 'returns 409 conflict error if same username exists' do
expect do
post api('/users', admin),
name: 'foo',
@@ -246,7 +246,7 @@ describe API::API, api: true do
end
describe "GET /users/sign_up" do
- it "should redirect to sign in page" do
+ it "redirects to sign in page" do
get "/users/sign_up"
expect(response).to have_http_status(302)
expect(response).to redirect_to(new_user_session_path)
@@ -258,55 +258,55 @@ describe API::API, api: true do
before { admin }
- it "should update user with new bio" do
+ it "updates user with new bio" do
put api("/users/#{user.id}", admin), { bio: 'new test bio' }
expect(response).to have_http_status(200)
expect(json_response['bio']).to eq('new test bio')
expect(user.reload.bio).to eq('new test bio')
end
- it 'should update user with his own email' do
+ it 'updates user with his own email' do
put api("/users/#{user.id}", admin), email: user.email
expect(response).to have_http_status(200)
expect(json_response['email']).to eq(user.email)
expect(user.reload.email).to eq(user.email)
end
- it 'should update user with his own username' do
+ it 'updates user with his own username' do
put api("/users/#{user.id}", admin), username: user.username
expect(response).to have_http_status(200)
expect(json_response['username']).to eq(user.username)
expect(user.reload.username).to eq(user.username)
end
- it "should update user's existing identity" do
+ it "updates user's existing identity" do
put api("/users/#{omniauth_user.id}", admin), provider: 'ldapmain', extern_uid: '654321'
expect(response).to have_http_status(200)
expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321')
end
- it 'should update user with new identity' do
+ it 'updates user with new identity' do
put api("/users/#{user.id}", admin), provider: 'github', extern_uid: '67890'
expect(response).to have_http_status(200)
expect(user.reload.identities.first.extern_uid).to eq('67890')
expect(user.reload.identities.first.provider).to eq('github')
end
- it "should update admin status" do
+ it "updates admin status" do
put api("/users/#{user.id}", admin), { admin: true }
expect(response).to have_http_status(200)
expect(json_response['is_admin']).to eq(true)
expect(user.reload.admin).to eq(true)
end
- it "should update external status" do
+ it "updates external status" do
put api("/users/#{user.id}", admin), { external: true }
expect(response.status).to eq 200
expect(json_response['external']).to eq(true)
expect(user.reload.external?).to be_truthy
end
- it "should not update admin status" do
+ it "does not update admin status" do
put api("/users/#{admin_user.id}", admin), { can_create_group: false }
expect(response).to have_http_status(200)
expect(json_response['is_admin']).to eq(true)
@@ -314,28 +314,28 @@ describe API::API, api: true do
expect(admin_user.can_create_group).to eq(false)
end
- it "should not allow invalid update" do
+ it "does not allow invalid update" do
put api("/users/#{user.id}", admin), { email: 'invalid email' }
expect(response).to have_http_status(400)
expect(user.reload.email).not_to eq('invalid email')
end
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
put api("/users/#{user.id}", user), attributes_for(:user)
expect(response).to have_http_status(403)
end
- it "should return 404 for non-existing user" do
+ it "returns 404 for non-existing user" do
put api("/users/999999", admin), { bio: 'update should fail' }
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{put api("/users/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
- it 'should return 400 error if user does not validate' do
+ it 'returns 400 error if user does not validate' do
put api("/users/#{user.id}", admin),
password: 'pass',
email: 'test@example.com',
@@ -361,13 +361,13 @@ describe API::API, api: true do
@user = User.all.last
end
- it 'should return 409 conflict error if email address exists' do
+ it 'returns 409 conflict error if email address exists' do
put api("/users/#{@user.id}", admin), email: 'test@example.com'
expect(response).to have_http_status(409)
expect(@user.reload.email).to eq(@user.email)
end
- it 'should return 409 conflict error if username taken' do
+ it 'returns 409 conflict error if username taken' do
@user_id = User.all.last.id
put api("/users/#{@user.id}", admin), username: 'test'
expect(response).to have_http_status(409)
@@ -379,28 +379,28 @@ describe API::API, api: true do
describe "POST /users/:id/keys" do
before { admin }
- it "should not create invalid ssh key" do
+ it "does not create invalid ssh key" do
post api("/users/#{user.id}/keys", admin), { title: "invalid key" }
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "key" not given')
end
- it 'should not create key without title' do
+ it 'does not create key without title' do
post api("/users/#{user.id}/keys", admin), key: 'some key'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "title" not given')
end
- it "should create ssh key" do
+ it "creates ssh key" do
key_attrs = attributes_for :key
expect do
post api("/users/#{user.id}/keys", admin), key_attrs
end.to change{ user.keys.count }.by(1)
end
- it "should return 405 for invalid ID" do
- post api("/users/ASDF/keys", admin)
- expect(response).to have_http_status(405)
+ it "returns 400 for invalid ID" do
+ post api("/users/999999/keys", admin)
+ expect(response).to have_http_status(400)
end
end
@@ -408,20 +408,20 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/users/#{user.id}/keys")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return 404 for non-existing user' do
+ it 'returns 404 for non-existing user' do
get api('/users/999999/keys', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return array of ssh keys' do
+ it 'returns array of ssh keys' do
user.keys << key
user.save
get api("/users/#{user.id}/keys", admin)
@@ -429,11 +429,6 @@ describe API::API, api: true do
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(key.title)
end
-
- it "should return 405 for invalid ID" do
- get api("/users/ASDF/keys", admin)
- expect(response).to have_http_status(405)
- end
end
end
@@ -441,14 +436,14 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
delete api("/users/#{user.id}/keys/42")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should delete existing key' do
+ it 'deletes existing key' do
user.keys << key
user.save
expect do
@@ -457,7 +452,7 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it 'should return 404 error if user not found' do
+ it 'returns 404 error if user not found' do
user.keys << key
user.save
delete api("/users/999999/keys/#{key.id}", admin)
@@ -465,7 +460,7 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return 404 error if key not foud' do
+ it 'returns 404 error if key not foud' do
delete api("/users/#{user.id}/keys/42", admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Key Not Found')
@@ -476,22 +471,22 @@ describe API::API, api: true do
describe "POST /users/:id/emails" do
before { admin }
- it "should not create invalid email" do
+ it "does not create invalid email" do
post api("/users/#{user.id}/emails", admin), {}
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "email" not given')
end
- it "should create email" do
+ it "creates email" do
email_attrs = attributes_for :email
expect do
post api("/users/#{user.id}/emails", admin), email_attrs
end.to change{ user.emails.count }.by(1)
end
- it "should raise error for invalid ID" do
- post api("/users/ASDF/emails", admin)
- expect(response).to have_http_status(405)
+ it "raises error for invalid ID" do
+ post api("/users/999999/emails", admin)
+ expect(response).to have_http_status(400)
end
end
@@ -499,20 +494,20 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
get api("/users/#{user.id}/emails")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should return 404 for non-existing user' do
+ it 'returns 404 for non-existing user' do
get api('/users/999999/emails', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return array of emails' do
+ it 'returns array of emails' do
user.emails << email
user.save
get api("/users/#{user.id}/emails", admin)
@@ -521,7 +516,7 @@ describe API::API, api: true do
expect(json_response.first['email']).to eq(email.email)
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
put api("/users/ASDF/emails", admin)
expect(response).to have_http_status(405)
end
@@ -532,14 +527,14 @@ describe API::API, api: true do
before { admin }
context 'when unauthenticated' do
- it 'should return authentication error' do
+ it 'returns authentication error' do
delete api("/users/#{user.id}/emails/42")
expect(response).to have_http_status(401)
end
end
context 'when authenticated' do
- it 'should delete existing email' do
+ it 'deletes existing email' do
user.emails << email
user.save
expect do
@@ -548,7 +543,7 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it 'should return 404 error if user not found' do
+ it 'returns 404 error if user not found' do
user.emails << email
user.save
delete api("/users/999999/emails/#{email.id}", admin)
@@ -556,13 +551,13 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 User Not Found')
end
- it 'should return 404 error if email not foud' do
+ it 'returns 404 error if email not foud' do
delete api("/users/#{user.id}/emails/42", admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Email Not Found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/ASDF/emails/bar", admin) }.to raise_error(ActionController::RoutingError)
end
end
@@ -571,36 +566,36 @@ describe API::API, api: true do
describe "DELETE /users/:id" do
before { admin }
- it "should delete user" do
+ it "deletes user" do
delete api("/users/#{user.id}", admin)
expect(response).to have_http_status(200)
expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound
expect(json_response['email']).to eq(user.email)
end
- it "should not delete for unauthenticated user" do
+ it "does not delete for unauthenticated user" do
delete api("/users/#{user.id}")
expect(response).to have_http_status(401)
end
- it "shouldn't available for non admin users" do
+ it "is not available for non admin users" do
delete api("/users/#{user.id}", user)
expect(response).to have_http_status(403)
end
- it "should return 404 for non-existing user" do
+ it "returns 404 for non-existing user" do
delete api("/users/999999", admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
end
describe "GET /user" do
- it "should return current user" do
+ it "returns current user" do
get api("/user", user)
expect(response).to have_http_status(200)
expect(json_response['email']).to eq(user.email)
@@ -610,7 +605,7 @@ describe API::API, api: true do
expect(json_response['projects_limit']).to eq(user.projects_limit)
end
- it "should return 401 error if user is unauthenticated" do
+ it "returns 401 error if user is unauthenticated" do
get api("/user")
expect(response).to have_http_status(401)
end
@@ -618,14 +613,14 @@ describe API::API, api: true do
describe "GET /user/keys" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/user/keys")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return array of ssh keys" do
+ it "returns array of ssh keys" do
user.keys << key
user.save
get api("/user/keys", user)
@@ -637,7 +632,7 @@ describe API::API, api: true do
end
describe "GET /user/keys/:id" do
- it "should return single key" do
+ it "returns single key" do
user.keys << key
user.save
get api("/user/keys/#{key.id}", user)
@@ -645,13 +640,13 @@ describe API::API, api: true do
expect(json_response["title"]).to eq(key.title)
end
- it "should return 404 Not Found within invalid ID" do
+ it "returns 404 Not Found within invalid ID" do
get api("/user/keys/42", user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 error if admin accesses user's ssh key" do
+ it "returns 404 error if admin accesses user's ssh key" do
user.keys << key
user.save
admin
@@ -660,14 +655,14 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 for invalid ID" do
+ it "returns 404 for invalid ID" do
get api("/users/keys/ASDF", admin)
expect(response).to have_http_status(404)
end
end
describe "POST /user/keys" do
- it "should create ssh key" do
+ it "creates ssh key" do
key_attrs = attributes_for :key
expect do
post api("/user/keys", user), key_attrs
@@ -675,31 +670,31 @@ describe API::API, api: true do
expect(response).to have_http_status(201)
end
- it "should return a 401 error if unauthorized" do
+ it "returns a 401 error if unauthorized" do
post api("/user/keys"), title: 'some title', key: 'some key'
expect(response).to have_http_status(401)
end
- it "should not create ssh key without key" do
+ it "does not create ssh key without key" do
post api("/user/keys", user), title: 'title'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "key" not given')
end
- it 'should not create ssh key without title' do
+ it 'does not create ssh key without title' do
post api('/user/keys', user), key: 'some key'
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "title" not given')
end
- it "should not create ssh key without title" do
+ it "does not create ssh key without title" do
post api("/user/keys", user), key: "somekey"
expect(response).to have_http_status(400)
end
end
describe "DELETE /user/keys/:id" do
- it "should delete existed key" do
+ it "deletes existed key" do
user.keys << key
user.save
expect do
@@ -708,33 +703,33 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return success if key ID not found" do
+ it "returns success if key ID not found" do
delete api("/user/keys/42", user)
expect(response).to have_http_status(200)
end
- it "should return 401 error if unauthorized" do
+ it "returns 401 error if unauthorized" do
user.keys << key
user.save
delete api("/user/keys/#{key.id}")
expect(response).to have_http_status(401)
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/keys/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
end
describe "GET /user/emails" do
context "when unauthenticated" do
- it "should return authentication error" do
+ it "returns authentication error" do
get api("/user/emails")
expect(response).to have_http_status(401)
end
end
context "when authenticated" do
- it "should return array of emails" do
+ it "returns array of emails" do
user.emails << email
user.save
get api("/user/emails", user)
@@ -746,7 +741,7 @@ describe API::API, api: true do
end
describe "GET /user/emails/:id" do
- it "should return single email" do
+ it "returns single email" do
user.emails << email
user.save
get api("/user/emails/#{email.id}", user)
@@ -754,13 +749,13 @@ describe API::API, api: true do
expect(json_response["email"]).to eq(email.email)
end
- it "should return 404 Not Found within invalid ID" do
+ it "returns 404 Not Found within invalid ID" do
get api("/user/emails/42", user)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 error if admin accesses user's email" do
+ it "returns 404 error if admin accesses user's email" do
user.emails << email
user.save
admin
@@ -769,14 +764,14 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 Not found')
end
- it "should return 404 for invalid ID" do
+ it "returns 404 for invalid ID" do
get api("/users/emails/ASDF", admin)
expect(response).to have_http_status(404)
end
end
describe "POST /user/emails" do
- it "should create email" do
+ it "creates email" do
email_attrs = attributes_for :email
expect do
post api("/user/emails", user), email_attrs
@@ -784,12 +779,12 @@ describe API::API, api: true do
expect(response).to have_http_status(201)
end
- it "should return a 401 error if unauthorized" do
+ it "returns a 401 error if unauthorized" do
post api("/user/emails"), email: 'some email'
expect(response).to have_http_status(401)
end
- it "should not create email with invalid email" do
+ it "does not create email with invalid email" do
post api("/user/emails", user), {}
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 (Bad request) "email" not given')
@@ -797,7 +792,7 @@ describe API::API, api: true do
end
describe "DELETE /user/emails/:id" do
- it "should delete existed email" do
+ it "deletes existed email" do
user.emails << email
user.save
expect do
@@ -806,44 +801,44 @@ describe API::API, api: true do
expect(response).to have_http_status(200)
end
- it "should return success if email ID not found" do
+ it "returns success if email ID not found" do
delete api("/user/emails/42", user)
expect(response).to have_http_status(200)
end
- it "should return 401 error if unauthorized" do
+ it "returns 401 error if unauthorized" do
user.emails << email
user.save
delete api("/user/emails/#{email.id}")
expect(response).to have_http_status(401)
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{delete api("/users/emails/ASDF", admin) }.to raise_error(ActionController::RoutingError)
end
end
describe 'PUT /user/:id/block' do
before { admin }
- it 'should block existing user' do
+ it 'blocks existing user' do
put api("/users/#{user.id}/block", admin)
expect(response).to have_http_status(200)
expect(user.reload.state).to eq('blocked')
end
- it 'should not re-block ldap blocked users' do
+ it 'does not re-block ldap blocked users' do
put api("/users/#{ldap_blocked_user.id}/block", admin)
expect(response).to have_http_status(403)
expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
end
- it 'should not be available for non admin users' do
+ it 'does not be available for non admin users' do
put api("/users/#{user.id}/block", user)
expect(response).to have_http_status(403)
expect(user.reload.state).to eq('active')
end
- it 'should return a 404 error if user id not found' do
+ it 'returns a 404 error if user id not found' do
put api('/users/9999/block', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
@@ -854,37 +849,37 @@ describe API::API, api: true do
let(:blocked_user) { create(:user, state: 'blocked') }
before { admin }
- it 'should unblock existing user' do
+ it 'unblocks existing user' do
put api("/users/#{user.id}/unblock", admin)
expect(response).to have_http_status(200)
expect(user.reload.state).to eq('active')
end
- it 'should unblock a blocked user' do
+ it 'unblocks a blocked user' do
put api("/users/#{blocked_user.id}/unblock", admin)
expect(response).to have_http_status(200)
expect(blocked_user.reload.state).to eq('active')
end
- it 'should not unblock ldap blocked users' do
+ it 'does not unblock ldap blocked users' do
put api("/users/#{ldap_blocked_user.id}/unblock", admin)
expect(response).to have_http_status(403)
expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
end
- it 'should not be available for non admin users' do
+ it 'does not be available for non admin users' do
put api("/users/#{user.id}/unblock", user)
expect(response).to have_http_status(403)
expect(user.reload.state).to eq('active')
end
- it 'should return a 404 error if user id not found' do
+ it 'returns a 404 error if user id not found' do
put api('/users/9999/block', admin)
expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
- it "should raise error for invalid ID" do
+ it "raises error for invalid ID" do
expect{put api("/users/ASDF/block", admin) }.to raise_error(ActionController::RoutingError)
end
end
diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb
index ddba18245f8..05fbdb909dc 100644
--- a/spec/requests/api/variables_spec.rb
+++ b/spec/requests/api/variables_spec.rb
@@ -12,7 +12,7 @@ describe API::API, api: true do
describe 'GET /projects/:id/variables' do
context 'authorized user with proper permissions' do
- it 'should return project variables' do
+ it 'returns project variables' do
get api("/projects/#{project.id}/variables", user)
expect(response).to have_http_status(200)
@@ -21,7 +21,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not return project variables' do
+ it 'does not return project variables' do
get api("/projects/#{project.id}/variables", user2)
expect(response).to have_http_status(403)
@@ -29,7 +29,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not return project variables' do
+ it 'does not return project variables' do
get api("/projects/#{project.id}/variables")
expect(response).to have_http_status(401)
@@ -39,14 +39,14 @@ describe API::API, api: true do
describe 'GET /projects/:id/variables/:key' do
context 'authorized user with proper permissions' do
- it 'should return project variable details' do
+ it 'returns project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user)
expect(response).to have_http_status(200)
expect(json_response['value']).to eq(variable.value)
end
- it 'should respond with 404 Not Found if requesting non-existing variable' do
+ it 'responds with 404 Not Found if requesting non-existing variable' do
get api("/projects/#{project.id}/variables/non_existing_variable", user)
expect(response).to have_http_status(404)
@@ -54,7 +54,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not return project variable details' do
+ it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_http_status(403)
@@ -62,7 +62,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not return project variable details' do
+ it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_http_status(401)
@@ -72,7 +72,7 @@ describe API::API, api: true do
describe 'POST /projects/:id/variables' do
context 'authorized user with proper permissions' do
- it 'should create variable' do
+ it 'creates variable' do
expect do
post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2'
end.to change{project.variables.count}.by(1)
@@ -82,7 +82,7 @@ describe API::API, api: true do
expect(json_response['value']).to eq('VALUE_2')
end
- it 'should not allow to duplicate variable key' do
+ it 'does not allow to duplicate variable key' do
expect do
post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2'
end.to change{project.variables.count}.by(0)
@@ -92,7 +92,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not create variable' do
+ it 'does not create variable' do
post api("/projects/#{project.id}/variables", user2)
expect(response).to have_http_status(403)
@@ -100,7 +100,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not create variable' do
+ it 'does not create variable' do
post api("/projects/#{project.id}/variables")
expect(response).to have_http_status(401)
@@ -110,7 +110,7 @@ describe API::API, api: true do
describe 'PUT /projects/:id/variables/:key' do
context 'authorized user with proper permissions' do
- it 'should update variable data' do
+ it 'updates variable data' do
initial_variable = project.variables.first
value_before = initial_variable.value
@@ -123,7 +123,7 @@ describe API::API, api: true do
expect(updated_variable.value).to eq('VALUE_1_UP')
end
- it 'should responde with 404 Not Found if requesting non-existing variable' do
+ it 'responds with 404 Not Found if requesting non-existing variable' do
put api("/projects/#{project.id}/variables/non_existing_variable", user)
expect(response).to have_http_status(404)
@@ -131,7 +131,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not update variable' do
+ it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_http_status(403)
@@ -139,7 +139,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not update variable' do
+ it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_http_status(401)
@@ -149,14 +149,14 @@ describe API::API, api: true do
describe 'DELETE /projects/:id/variables/:key' do
context 'authorized user with proper permissions' do
- it 'should delete variable' do
+ it 'deletes variable' do
expect do
delete api("/projects/#{project.id}/variables/#{variable.key}", user)
end.to change{project.variables.count}.by(-1)
expect(response).to have_http_status(200)
end
- it 'should responde with 404 Not Found if requesting non-existing variable' do
+ it 'responds with 404 Not Found if requesting non-existing variable' do
delete api("/projects/#{project.id}/variables/non_existing_variable", user)
expect(response).to have_http_status(404)
@@ -164,7 +164,7 @@ describe API::API, api: true do
end
context 'authorized user with invalid permissions' do
- it 'should not delete variable' do
+ it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_http_status(403)
@@ -172,7 +172,7 @@ describe API::API, api: true do
end
context 'unauthorized user' do
- it 'should not delete variable' do
+ it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_http_status(401)
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index 66eebe69b5d..ca7932dc5da 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -16,7 +16,7 @@ describe Ci::API::API do
describe "POST /builds/register" do
let!(:build) { create(:ci_build, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
- it "should start a build" do
+ it "starts a build" do
register_builds info: { platform: :darwin }
expect(response).to have_http_status(201)
@@ -35,7 +35,7 @@ describe Ci::API::API do
build.success
end
- it "should return 404 error if no pending build found" do
+ it "returns 404 error if no builds for specific runner" do
register_builds
expect(response).to have_http_status(404)
@@ -48,7 +48,7 @@ describe Ci::API::API do
create(:ci_build, :pending)
end
- it "should return 404 error if no builds for specific runner" do
+ it "returns 404 error if no builds for shared runner" do
register_builds
expect(response).to have_http_status(404)
@@ -159,18 +159,18 @@ describe Ci::API::API do
put ci_api("/builds/#{build.id}"), token: runner.token
end
- it "should update a running build" do
+ it "updates a running build" do
expect(response).to have_http_status(200)
end
- it 'should not override trace information when no trace is given' do
+ it 'does not override trace information when no trace is given' do
expect(build.reload.trace).to eq 'BUILD TRACE'
end
context 'build has been erased' do
let(:build) { create(:ci_build, runner_id: runner.id, erased_at: Time.now) }
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response.status).to eq 403
end
end
@@ -267,7 +267,7 @@ describe Ci::API::API do
context 'authorization token is invalid' do
before { post authorize_url, { token: 'invalid', filesize: 100 } }
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response).to have_http_status(403)
end
end
@@ -287,7 +287,7 @@ describe Ci::API::API do
upload_artifacts(file_upload, headers_with_token)
end
- it 'should respond with forbidden' do
+ it 'responds with forbidden' do
expect(response.status).to eq 403
end
end
@@ -329,7 +329,7 @@ describe Ci::API::API do
end
end
- context 'should post artifacts file and metadata file' do
+ context 'posts artifacts file and metadata file' do
let!(:artifacts) { file_upload }
let!(:metadata) { file_upload2 }
@@ -341,7 +341,7 @@ describe Ci::API::API do
post(post_url, post_data, headers_with_token)
end
- context 'post data accelerated by workhorse is correct' do
+ context 'posts data accelerated by workhorse is correct' do
let(:post_data) do
{ 'file.path' => artifacts.path,
'file.name' => artifacts.original_filename,
@@ -409,7 +409,7 @@ describe Ci::API::API do
end
context "artifacts file is too large" do
- it "should fail to post too large artifact" do
+ it "fails to post too large artifact" do
stub_application_setting(max_artifacts_size: 0)
upload_artifacts(file_upload, headers_with_token)
expect(response).to have_http_status(413)
@@ -417,14 +417,14 @@ describe Ci::API::API do
end
context "artifacts post request does not contain file" do
- it "should fail to post artifacts without file" do
+ it "fails to post artifacts without file" do
post post_url, {}, headers_with_token
expect(response).to have_http_status(400)
end
end
context 'GitLab Workhorse is not configured' do
- it "should fail to post artifacts without GitLab-Workhorse" do
+ it "fails to post artifacts without GitLab-Workhorse" do
post post_url, { token: build.token }, {}
expect(response).to have_http_status(403)
end
@@ -443,7 +443,7 @@ describe Ci::API::API do
FileUtils.remove_entry @tmpdir
end
- it "should fail to post artifacts for outside of tmp path" do
+ it "fails to post artifacts for outside of tmp path" do
upload_artifacts(file_upload, headers_with_token)
expect(response).to have_http_status(400)
end
@@ -469,7 +469,7 @@ describe Ci::API::API do
build.reload
end
- it 'should remove build artifacts' do
+ it 'removes build artifacts' do
expect(response).to have_http_status(200)
expect(build.artifacts_file.exists?).to be_falsy
expect(build.artifacts_metadata.exists?).to be_falsy
@@ -487,14 +487,14 @@ describe Ci::API::API do
'Content-Disposition' => 'attachment; filename=ci_build_artifacts.zip' }
end
- it 'should download artifact' do
+ it 'downloads artifact' do
expect(response).to have_http_status(200)
expect(response.headers).to include download_headers
end
end
context 'build does not has artifacts' do
- it 'should respond with not found' do
+ it 'responds with not found' do
expect(response).to have_http_status(404)
end
end
diff --git a/spec/requests/ci/api/triggers_spec.rb b/spec/requests/ci/api/triggers_spec.rb
index 071450b29dc..0a0f979f57d 100644
--- a/spec/requests/ci/api/triggers_spec.rb
+++ b/spec/requests/ci/api/triggers_spec.rb
@@ -19,17 +19,17 @@ describe Ci::API::API do
end
context 'Handles errors' do
- it 'should return bad request if token is missing' do
+ it 'returns bad request if token is missing' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger")
expect(response).to have_http_status(400)
end
- it 'should return not found if project is not found' do
+ it 'returns not found if project is not found' do
post ci_api('/projects/0/refs/master/trigger'), options
expect(response).to have_http_status(404)
end
- it 'should return unauthorized if token is for different project' do
+ it 'returns unauthorized if token is for different project' do
post ci_api("/projects/#{project2.ci_id}/refs/master/trigger"), options
expect(response).to have_http_status(401)
end
@@ -38,7 +38,7 @@ describe Ci::API::API do
context 'Have a commit' do
let(:pipeline) { project.pipelines.last }
- it 'should create builds' do
+ it 'creates builds' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options
expect(response).to have_http_status(201)
pipeline.builds.reload
@@ -46,7 +46,7 @@ describe Ci::API::API do
expect(pipeline.builds.size).to eq(5)
end
- it 'should return bad request with no builds created if there\'s no commit for that ref' do
+ it 'returns bad request with no builds created if there\'s no commit for that ref' do
post ci_api("/projects/#{project.ci_id}/refs/other-branch/trigger"), options
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('No builds created')
@@ -57,19 +57,19 @@ describe Ci::API::API do
{ 'TRIGGER_KEY' => 'TRIGGER_VALUE' }
end
- it 'should validate variables to be a hash' do
+ it 'validates variables to be a hash' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: 'value')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a hash')
end
- it 'should validate variables needs to be a map of key-valued strings' do
+ it 'validates variables needs to be a map of key-valued strings' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: { key: %w(1 2) })
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('variables needs to be a map of key-valued strings')
end
- it 'create trigger request with variables' do
+ it 'creates trigger request with variables' do
post ci_api("/projects/#{project.ci_id}/refs/master/trigger"), options.merge(variables: variables)
expect(response).to have_http_status(201)
pipeline.builds.reload
diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb
index 82ab582beac..8537c252b58 100644
--- a/spec/requests/git_http_spec.rb
+++ b/spec/requests/git_http_spec.rb
@@ -75,9 +75,9 @@ describe 'Git HTTP requests', lib: true do
context "with correct credentials" do
let(:env) { { user: user.username, password: user.password } }
- it "uploads get status 200 (because Git hooks do the real check)" do
+ it "uploads get status 403" do
upload(path, env) do |response|
- expect(response).to have_http_status(200)
+ expect(response).to have_http_status(403)
end
end
@@ -86,7 +86,7 @@ describe 'Git HTTP requests', lib: true do
allow(Gitlab.config.gitlab_shell).to receive(:receive_pack).and_return(false)
upload(path, env) do |response|
- expect(response).to have_http_status(404)
+ expect(response).to have_http_status(403)
end
end
end
@@ -236,9 +236,9 @@ describe 'Git HTTP requests', lib: true do
end
end
- it "uploads get status 200 (because Git hooks do the real check)" do
+ it "uploads get status 404" do
upload(path, user: user.username, password: user.password) do |response|
- expect(response).to have_http_status(200)
+ expect(response).to have_http_status(404)
end
end
end
@@ -349,19 +349,19 @@ describe 'Git HTTP requests', lib: true do
end
end
- def clone_get(project, options={})
+ def clone_get(project, options = {})
get "/#{project}/info/refs", { service: 'git-upload-pack' }, auth_env(*options.values_at(:user, :password, :spnego_request_token))
end
- def clone_post(project, options={})
+ def clone_post(project, options = {})
post "/#{project}/git-upload-pack", {}, auth_env(*options.values_at(:user, :password, :spnego_request_token))
end
- def push_get(project, options={})
+ def push_get(project, options = {})
get "/#{project}/info/refs", { service: 'git-receive-pack' }, auth_env(*options.values_at(:user, :password, :spnego_request_token))
end
- def push_post(project, options={})
+ def push_post(project, options = {})
post "/#{project}/git-receive-pack", {}, auth_env(*options.values_at(:user, :password, :spnego_request_token))
end
diff --git a/spec/services/create_snippet_service_spec.rb b/spec/services/create_snippet_service_spec.rb
index 7a850066bf8..d81d0fd76c9 100644
--- a/spec/services/create_snippet_service_spec.rb
+++ b/spec/services/create_snippet_service_spec.rb
@@ -19,7 +19,7 @@ describe CreateSnippetService, services: true do
@opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
- it 'non-admins should not be able to create a public snippet' do
+ it 'non-admins are not able to create a public snippet' do
snippet = create_snippet(nil, @user, @opts)
expect(snippet.errors.messages).to have_key(:visibility_level)
expect(snippet.errors.messages[:visibility_level].first).to(
@@ -27,7 +27,7 @@ describe CreateSnippetService, services: true do
)
end
- it 'admins should be able to create a public snippet' do
+ it 'admins are able to create a public snippet' do
snippet = create_snippet(nil, @admin, @opts)
expect(snippet.errors.any?).to be_falsey
expect(snippet.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb
index 789836f71bb..16a9956fe7f 100644
--- a/spec/services/event_create_service_spec.rb
+++ b/spec/services/event_create_service_spec.rb
@@ -41,7 +41,7 @@ describe EventCreateService, services: true do
it { expect(service.open_mr(merge_request, merge_request.author)).to be_truthy }
- it "should create new event" do
+ it "creates new event" do
expect { service.open_mr(merge_request, merge_request.author) }.to change { Event.count }
end
end
@@ -51,7 +51,7 @@ describe EventCreateService, services: true do
it { expect(service.close_mr(merge_request, merge_request.author)).to be_truthy }
- it "should create new event" do
+ it "creates new event" do
expect { service.close_mr(merge_request, merge_request.author) }.to change { Event.count }
end
end
@@ -61,7 +61,7 @@ describe EventCreateService, services: true do
it { expect(service.merge_mr(merge_request, merge_request.author)).to be_truthy }
- it "should create new event" do
+ it "creates new event" do
expect { service.merge_mr(merge_request, merge_request.author) }.to change { Event.count }
end
end
@@ -71,7 +71,7 @@ describe EventCreateService, services: true do
it { expect(service.reopen_mr(merge_request, merge_request.author)).to be_truthy }
- it "should create new event" do
+ it "creates new event" do
expect { service.reopen_mr(merge_request, merge_request.author) }.to change { Event.count }
end
end
@@ -85,7 +85,7 @@ describe EventCreateService, services: true do
it { expect(service.open_milestone(milestone, user)).to be_truthy }
- it "should create new event" do
+ it "creates new event" do
expect { service.open_milestone(milestone, user) }.to change { Event.count }
end
end
@@ -95,7 +95,7 @@ describe EventCreateService, services: true do
it { expect(service.close_milestone(milestone, user)).to be_truthy }
- it "should create new event" do
+ it "creates new event" do
expect { service.close_milestone(milestone, user) }.to change { Event.count }
end
end
@@ -105,7 +105,7 @@ describe EventCreateService, services: true do
it { expect(service.destroy_milestone(milestone, user)).to be_truthy }
- it "should create new event" do
+ it "creates new event" do
expect { service.destroy_milestone(milestone, user) }.to change { Event.count }
end
end
diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb
index 3fc37a315c0..41b0968b8b4 100644
--- a/spec/services/git_hooks_service_spec.rb
+++ b/spec/services/git_hooks_service_spec.rb
@@ -17,7 +17,7 @@ describe GitHooksService, services: true do
describe '#execute' do
context 'when receive hooks were successful' do
- it 'should call post-receive hook' do
+ it 'calls post-receive hook' do
hook = double(trigger: [true, nil])
expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook)
@@ -26,7 +26,7 @@ describe GitHooksService, services: true do
end
context 'when pre-receive hook failed' do
- it 'should not call post-receive hook' do
+ it 'does not call post-receive hook' do
expect(service).to receive(:run_hook).with('pre-receive').and_return([false, ''])
expect(service).not_to receive(:run_hook).with('post-receive')
@@ -37,7 +37,7 @@ describe GitHooksService, services: true do
end
context 'when update hook failed' do
- it 'should not call post-receive hook' do
+ it 'does not call post-receive hook' do
expect(service).to receive(:run_hook).with('pre-receive').and_return([true, nil])
expect(service).to receive(:run_hook).with('update').and_return([false, ''])
expect(service).not_to receive(:run_hook).with('post-receive')
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index ffa998dffc3..80f6ebac86c 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -420,7 +420,7 @@ describe GitPushService, services: true do
context "mentioning an issue" do
let(:message) { "this is some work.\n\nrelated to JIRA-1" }
- it "should initiate one api call to jira server to mention the issue" do
+ it "initiates one api call to jira server to mention the issue" do
execute_service(project, user, @oldrev, @newrev, @ref )
expect(WebMock).to have_requested(:post, jira_api_comment_url).with(
@@ -432,7 +432,7 @@ describe GitPushService, services: true do
context "closing an issue" do
let(:message) { "this is some work.\n\ncloses JIRA-1" }
- it "should initiate one api call to jira server to close the issue" do
+ it "initiates one api call to jira server to close the issue" do
transition_body = {
transition: {
id: '2'
@@ -445,7 +445,7 @@ describe GitPushService, services: true do
).once
end
- it "should initiate one api call to jira server to comment on the issue" do
+ it "initiates one api call to jira server to comment on the issue" do
comment_body = {
body: "Issue solved with [#{closing_commit.id}|http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}]."
}.to_json
diff --git a/spec/services/issues/bulk_update_service_spec.rb b/spec/services/issues/bulk_update_service_spec.rb
index 321b54ac39d..ac08aa53b0b 100644
--- a/spec/services/issues/bulk_update_service_spec.rb
+++ b/spec/services/issues/bulk_update_service_spec.rb
@@ -217,7 +217,7 @@ describe Issues::BulkUpdateService, services: true do
let(:labels) { [merge_requests] }
let(:remove_labels) { [regression] }
- it 'remove the label IDs from all issues passed' do
+ it 'removes the label IDs from all issues passed' do
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(regression.id)
end
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index 67a919ba8ee..1318607a388 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -23,13 +23,13 @@ describe Issues::CloseService, services: true do
it { expect(@issue).to be_valid }
it { expect(@issue).to be_closed }
- it 'should send email to user2 about assign of new issue' do
+ it 'sends email to user2 about assign of new issue' do
email = ActionMailer::Base.deliveries.last
expect(email.to.first).to eq(user2.email)
expect(email.subject).to include(issue.title)
end
- it 'should create system note about issue reassign' do
+ it 'creates system note about issue reassign' do
note = @issue.notes.last
expect(note.note).to include "Status changed to closed"
end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index dacbcd8fb46..088c3d48bf7 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -53,7 +53,7 @@ describe Issues::UpdateService, services: true do
it { expect(@issue.labels.count).to eq(1) }
it { expect(@issue.labels.first.title).to eq(label.name) }
- it 'should send email to user2 about assign of new issue and email to user3 about issue unassignment' do
+ it 'sends email to user2 about assign of new issue and email to user3 about issue unassignment' do
deliveries = ActionMailer::Base.deliveries
email = deliveries.last
recipients = deliveries.last(2).map(&:to).flatten
@@ -61,14 +61,14 @@ describe Issues::UpdateService, services: true do
expect(email.subject).to include(issue.title)
end
- it 'should create system note about issue reassign' do
+ it 'creates system note about issue reassign' do
note = find_note('Reassigned to')
expect(note).not_to be_nil
expect(note.note).to include "Reassigned to \@#{user2.username}"
end
- it 'should create system note about issue label edit' do
+ it 'creates system note about issue label edit' do
note = find_note('Added ~')
expect(note).not_to be_nil
@@ -267,7 +267,7 @@ describe Issues::UpdateService, services: true do
expect(note).to be_nil
end
- it 'should not generate a new note at all' do
+ it 'does not generate a new note at all' do
expect do
update_issue({ description: "- [ ] One\n- [ ] Two\n- [ ] Three" })
end.not_to change { Note.count }
diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb
index c1db4f3284b..403533be5d9 100644
--- a/spec/services/merge_requests/close_service_spec.rb
+++ b/spec/services/merge_requests/close_service_spec.rb
@@ -32,13 +32,13 @@ describe MergeRequests::CloseService, services: true do
with(@merge_request, 'close')
end
- it 'should send email to user2 about assign of new merge_request' do
+ it 'sends email to user2 about assign of new merge_request' do
email = ActionMailer::Base.deliveries.last
expect(email.to.first).to eq(user2.email)
expect(email.subject).to include(merge_request.title)
end
- it 'should create system note about merge_request reassign' do
+ it 'creates system note about merge_request reassign' do
note = @merge_request.notes.last
expect(note.note).to include 'Status changed to closed'
end
diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb
index d0b55d2d509..b84a580967a 100644
--- a/spec/services/merge_requests/create_service_spec.rb
+++ b/spec/services/merge_requests/create_service_spec.rb
@@ -32,7 +32,7 @@ describe MergeRequests::CreateService, services: true do
it { expect(@merge_request.assignee).to be_nil }
it { expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1') }
- it 'should execute hooks with default action' do
+ it 'executes hooks with default action' do
expect(service).to have_received(:execute_hooks).with(@merge_request)
end
diff --git a/spec/services/merge_requests/merge_request_diff_cache_service_spec.rb b/spec/services/merge_requests/merge_request_diff_cache_service_spec.rb
index 8f71d71b0f0..c4b87468275 100644
--- a/spec/services/merge_requests/merge_request_diff_cache_service_spec.rb
+++ b/spec/services/merge_requests/merge_request_diff_cache_service_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
describe MergeRequests::MergeRequestDiffCacheService do
-
let(:subject) { MergeRequests::MergeRequestDiffCacheService.new }
describe '#execute' do
diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb
index 8ffebcac698..159f6817e8d 100644
--- a/spec/services/merge_requests/merge_service_spec.rb
+++ b/spec/services/merge_requests/merge_service_spec.rb
@@ -26,13 +26,13 @@ describe MergeRequests::MergeService, services: true do
it { expect(merge_request).to be_valid }
it { expect(merge_request).to be_merged }
- it 'should send email to user2 about merge of new merge_request' do
+ it 'sends email to user2 about merge of new merge_request' do
email = ActionMailer::Base.deliveries.last
expect(email.to.first).to eq(user2.email)
expect(email.subject).to include(merge_request.title)
end
- it 'should create system note about merge_request merge' do
+ it 'creates system note about merge_request merge' do
note = merge_request.notes.last
expect(note.note).to include 'Status changed to merged'
end
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 781ee7ffed3..fff86480c6d 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -55,7 +55,7 @@ describe MergeRequests::RefreshService, services: true do
reload_mrs
end
- it 'should execute hooks with update action' do
+ it 'executes hooks with update action' do
expect(refresh_service).to have_received(:execute_hooks).
with(@merge_request, 'update', @oldrev)
end
@@ -111,7 +111,7 @@ describe MergeRequests::RefreshService, services: true do
reload_mrs
end
- it 'should execute hooks with update action' do
+ it 'executes hooks with update action' do
expect(refresh_service).to have_received(:execute_hooks).
with(@fork_merge_request, 'update', @oldrev)
end
diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb
index 88c9c640514..3419b8bf5e6 100644
--- a/spec/services/merge_requests/reopen_service_spec.rb
+++ b/spec/services/merge_requests/reopen_service_spec.rb
@@ -27,18 +27,18 @@ describe MergeRequests::ReopenService, services: true do
it { expect(merge_request).to be_valid }
it { expect(merge_request).to be_reopened }
- it 'should execute hooks with reopen action' do
+ it 'executes hooks with reopen action' do
expect(service).to have_received(:execute_hooks).
with(merge_request, 'reopen')
end
- it 'should send email to user2 about reopen of merge_request' do
+ it 'sends email to user2 about reopen of merge_request' do
email = ActionMailer::Base.deliveries.last
expect(email.to.first).to eq(user2.email)
expect(email.subject).to include(merge_request.title)
end
- it 'should create system note about merge_request reopen' do
+ it 'creates system note about merge_request reopen' do
note = merge_request.notes.last
expect(note.note).to include 'Status changed to reopened'
end
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index d4ebe28c276..283a336afd9 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -64,12 +64,12 @@ describe MergeRequests::UpdateService, services: true do
it { expect(@merge_request.target_branch).to eq('target') }
it { expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1') }
- it 'should execute hooks with update action' do
+ it 'executes hooks with update action' do
expect(service).to have_received(:execute_hooks).
with(@merge_request, 'update')
end
- it 'should send email to user2 about assign of new merge request and email to user3 about merge request unassignment' do
+ it 'sends email to user2 about assign of new merge request and email to user3 about merge request unassignment' do
deliveries = ActionMailer::Base.deliveries
email = deliveries.last
recipients = deliveries.last(2).map(&:to).flatten
@@ -77,14 +77,14 @@ describe MergeRequests::UpdateService, services: true do
expect(email.subject).to include(merge_request.title)
end
- it 'should create system note about merge_request reassign' do
+ it 'creates system note about merge_request reassign' do
note = find_note('Reassigned to')
expect(note).not_to be_nil
expect(note.note).to include "Reassigned to \@#{user2.username}"
end
- it 'should create system note about merge_request label edit' do
+ it 'creates system note about merge_request label edit' do
note = find_note('Added ~')
expect(note).not_to be_nil
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 9fc93f325f7..92b441c28ca 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -15,7 +15,7 @@ describe NotificationService, services: true do
it { expect(notification.new_key(key)).to be_truthy }
- it 'should sent email to key owner' do
+ it 'sends email to key owner' do
expect{ notification.new_key(key) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
end
end
@@ -27,7 +27,7 @@ describe NotificationService, services: true do
it { expect(notification.new_email(email)).to be_truthy }
- it 'should send email to email owner' do
+ it 'sends email to email owner' do
expect{ notification.new_email(email) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
end
end
@@ -593,7 +593,7 @@ describe NotificationService, services: true do
update_custom_notification(:close_issue, @u_custom_global)
end
- it 'should sent email to issue assignee and issue author' do
+ it 'sends email to issue assignee and issue author' do
notification.close_issue(issue, @u_disabled)
should_email(issue.assignee)
@@ -646,7 +646,7 @@ describe NotificationService, services: true do
update_custom_notification(:reopen_issue, @u_custom_global)
end
- it 'should send email to issue assignee and issue author' do
+ it 'sends email to issue assignee and issue author' do
notification.reopen_issue(issue, @u_disabled)
should_email(issue.assignee)
diff --git a/spec/services/projects/autocomplete_service_spec.rb b/spec/services/projects/autocomplete_service_spec.rb
index 0971fec2e9f..7916c2d957c 100644
--- a/spec/services/projects/autocomplete_service_spec.rb
+++ b/spec/services/projects/autocomplete_service_spec.rb
@@ -13,7 +13,7 @@ describe Projects::AutocompleteService, services: true do
let!(:security_issue_1) { create(:issue, :confidential, project: project, title: 'Security issue 1', author: author) }
let!(:security_issue_2) { create(:issue, :confidential, title: 'Security issue 2', project: project, assignee: assignee) }
- it 'should not list project confidential issues for guests' do
+ it 'does not list project confidential issues for guests' do
autocomplete = described_class.new(project, nil)
issues = autocomplete.issues.map(&:iid)
@@ -23,7 +23,7 @@ describe Projects::AutocompleteService, services: true do
expect(issues.count).to eq 1
end
- it 'should not list project confidential issues for non project members' do
+ it 'does not list project confidential issues for non project members' do
autocomplete = described_class.new(project, non_member)
issues = autocomplete.issues.map(&:iid)
@@ -33,7 +33,7 @@ describe Projects::AutocompleteService, services: true do
expect(issues.count).to eq 1
end
- it 'should not list project confidential issues for project members with guest role' do
+ it 'does not list project confidential issues for project members with guest role' do
project.team << [member, :guest]
autocomplete = described_class.new(project, non_member)
@@ -45,7 +45,7 @@ describe Projects::AutocompleteService, services: true do
expect(issues.count).to eq 1
end
- it 'should list project confidential issues for author' do
+ it 'lists project confidential issues for author' do
autocomplete = described_class.new(project, author)
issues = autocomplete.issues.map(&:iid)
@@ -55,7 +55,7 @@ describe Projects::AutocompleteService, services: true do
expect(issues.count).to eq 2
end
- it 'should list project confidential issues for assignee' do
+ it 'lists project confidential issues for assignee' do
autocomplete = described_class.new(project, assignee)
issues = autocomplete.issues.map(&:iid)
@@ -65,7 +65,7 @@ describe Projects::AutocompleteService, services: true do
expect(issues.count).to eq 2
end
- it 'should list project confidential issues for project members' do
+ it 'lists project confidential issues for project members' do
project.team << [member, :developer]
autocomplete = described_class.new(project, member)
@@ -77,7 +77,7 @@ describe Projects::AutocompleteService, services: true do
expect(issues.count).to eq 3
end
- it 'should list all project issues for admin' do
+ it 'lists all project issues for admin' do
autocomplete = described_class.new(project, admin)
issues = autocomplete.issues.map(&:iid)
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index fd114359467..bbced59ff02 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -109,7 +109,7 @@ describe Projects::CreateService, services: true do
)
end
- it 'should not allow a restricted visibility level for non-admins' do
+ it 'does not allow a restricted visibility level for non-admins' do
project = create_project(@user, @opts)
expect(project).to respond_to(:errors)
expect(project.errors.messages).to have_key(:visibility_level)
@@ -118,7 +118,7 @@ describe Projects::CreateService, services: true do
)
end
- it 'should allow a restricted visibility level for admins' do
+ it 'allows a restricted visibility level for admins' do
admin = create(:admin)
project = create_project(admin, @opts)
@@ -128,7 +128,7 @@ describe Projects::CreateService, services: true do
end
context 'repository creation' do
- it 'should synchronously create the repository' do
+ it 'synchronously creates the repository' do
expect_any_instance_of(Project).to receive(:create_repository)
project = create_project(@user, @opts)
diff --git a/spec/services/projects/enable_deploy_key_service_spec.rb b/spec/services/projects/enable_deploy_key_service_spec.rb
new file mode 100644
index 00000000000..a37510cf159
--- /dev/null
+++ b/spec/services/projects/enable_deploy_key_service_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe Projects::EnableDeployKeyService, services: true do
+ let(:deploy_key) { create(:deploy_key, public: true) }
+ let(:project) { create(:empty_project) }
+ let(:user) { project.creator}
+ let!(:params) { { key_id: deploy_key.id } }
+
+ it 'enables the key' do
+ expect do
+ service.execute
+ end.to change { project.deploy_keys.count }.from(0).to(1)
+ end
+
+ context 'trying to add an unaccessable key' do
+ let(:another_key) { create(:another_key) }
+ let!(:params) { { key_id: another_key.id } }
+
+ it 'returns nil if the key cannot be added' do
+ expect(service.execute).to be nil
+ end
+ end
+
+ def service
+ Projects::EnableDeployKeyService.new(project, user, params)
+ end
+end
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 31bb7120d84..ef2036c78b1 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -26,7 +26,7 @@ describe Projects::ForkService, services: true do
end
context 'project already exists' do
- it "should fail due to validation, not transaction failure" do
+ it "fails due to validation, not transaction failure" do
@existing_project = create(:project, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@to_project = fork_project(@from_project, @to_user)
expect(@existing_project.persisted?).to be_truthy
@@ -36,7 +36,7 @@ describe Projects::ForkService, services: true do
end
context 'GitLab CI is enabled' do
- it "fork and enable CI for fork" do
+ it "forks and enables CI for fork" do
@from_project.enable_ci
@to_project = fork_project(@from_project, @to_user)
expect(@to_project.builds_enabled?).to be_truthy
@@ -97,14 +97,14 @@ describe Projects::ForkService, services: true do
end
context 'fork project for group when user not owner' do
- it 'group developer should fail to fork project into the group' do
+ it 'group developer fails to fork project into the group' do
to_project = fork_project(@project, @developer, @opts)
expect(to_project.errors[:namespace]).to eq(['is not valid'])
end
end
context 'project already exists in group' do
- it 'should fail due to validation, not transaction failure' do
+ it 'fails due to validation, not transaction failure' do
existing_project = create(:project, name: @project.name,
namespace: @group)
to_project = fork_project(@project, @group_owner, @opts)
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index e8b9e6b9238..e139be19140 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -9,7 +9,7 @@ describe Projects::UpdateService, services: true do
@opts = {}
end
- context 'should be private when updated to private' do
+ context 'is private when updated to private' do
before do
@created_private = @project.private?
@@ -21,7 +21,7 @@ describe Projects::UpdateService, services: true do
it { expect(@project.private?).to be_truthy }
end
- context 'should be internal when updated to internal' do
+ context 'is internal when updated to internal' do
before do
@created_private = @project.private?
@@ -33,7 +33,7 @@ describe Projects::UpdateService, services: true do
it { expect(@project.internal?).to be_truthy }
end
- context 'should be public when updated to public' do
+ context 'is public when updated to public' do
before do
@created_private = @project.private?
@@ -50,7 +50,7 @@ describe Projects::UpdateService, services: true do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- context 'should be private when updated to private' do
+ context 'is private when updated to private' do
before do
@created_private = @project.private?
@@ -62,7 +62,7 @@ describe Projects::UpdateService, services: true do
it { expect(@project.private?).to be_truthy }
end
- context 'should be internal when updated to internal' do
+ context 'is internal when updated to internal' do
before do
@created_private = @project.private?
@@ -74,7 +74,7 @@ describe Projects::UpdateService, services: true do
it { expect(@project.internal?).to be_truthy }
end
- context 'should be private when updated to public' do
+ context 'is private when updated to public' do
before do
@created_private = @project.private?
@@ -86,7 +86,7 @@ describe Projects::UpdateService, services: true do
it { expect(@project.private?).to be_truthy }
end
- context 'should be public when updated to public by admin' do
+ context 'is public when updated to public by admin' do
before do
@created_private = @project.private?
@@ -114,7 +114,7 @@ describe Projects::UpdateService, services: true do
@fork_created_internal = forked_project.internal?
end
- context 'should update forks visibility level when parent set to more restrictive' do
+ context 'updates forks visibility level when parent set to more restrictive' do
before do
opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
update_project(project, user, opts).inspect
@@ -126,7 +126,7 @@ describe Projects::UpdateService, services: true do
it { expect(project.forks.first.private?).to be_truthy }
end
- context 'should not update forks visibility level when parent set to less restrictive' do
+ context 'does not update forks visibility level when parent set to less restrictive' do
before do
opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
update_project(project, user, opts).inspect
diff --git a/spec/services/repair_ldap_blocked_user_service_spec.rb b/spec/services/repair_ldap_blocked_user_service_spec.rb
index ce7d1455975..87192457298 100644
--- a/spec/services/repair_ldap_blocked_user_service_spec.rb
+++ b/spec/services/repair_ldap_blocked_user_service_spec.rb
@@ -6,14 +6,14 @@ describe RepairLdapBlockedUserService, services: true do
subject(:service) { RepairLdapBlockedUserService.new(user) }
describe '#execute' do
- it 'change to normal block after destroying last ldap identity' do
+ it 'changes to normal block after destroying last ldap identity' do
identity.destroy
service.execute
expect(user.reload).not_to be_ldap_blocked
end
- it 'change to normal block after changing last ldap identity to another provider' do
+ it 'changes to normal block after changing last ldap identity to another provider' do
identity.update_attribute(:provider, 'twitter')
service.execute
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb
index 7b3a9a75d7c..bd89c4a7c11 100644
--- a/spec/services/search_service_spec.rb
+++ b/spec/services/search_service_spec.rb
@@ -16,7 +16,7 @@ describe 'Search::GlobalService', services: true do
describe '#execute' do
context 'unauthenticated' do
- it 'should return public projects only' do
+ it 'returns public projects only' do
context = Search::GlobalService.new(nil, search: "searchable")
results = context.execute
expect(results.objects('projects')).to match_array [public_project]
@@ -24,19 +24,19 @@ describe 'Search::GlobalService', services: true do
end
context 'authenticated' do
- it 'should return public, internal and private projects' do
+ it 'returns public, internal and private projects' do
context = Search::GlobalService.new(user, search: "searchable")
results = context.execute
expect(results.objects('projects')).to match_array [public_project, found_project, internal_project]
end
- it 'should return only public & internal projects' do
+ it 'returns only public & internal projects' do
context = Search::GlobalService.new(internal_user, search: "searchable")
results = context.execute
expect(results.objects('projects')).to match_array [internal_project, public_project]
end
- it 'namespace name should be searchable' do
+ it 'namespace name is searchable' do
context = Search::GlobalService.new(user, search: found_project.namespace.path)
results = context.execute
expect(results.objects('projects')).to match_array [found_project]
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index 43693441450..00427d6db2a 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -471,15 +471,15 @@ describe SystemNoteService, services: true do
shared_examples 'cross project mentionable' do
include GitlabMarkdownHelper
- it 'should contain cross reference to new noteable' do
+ it 'contains cross reference to new noteable' do
expect(subject.note).to include cross_project_reference(new_project, new_noteable)
end
- it 'should mention referenced noteable' do
+ it 'mentions referenced noteable' do
expect(subject.note).to include new_noteable.to_reference
end
- it 'should mention referenced project' do
+ it 'mentions referenced project' do
expect(subject.note).to include new_project.to_reference
end
end
@@ -489,7 +489,7 @@ describe SystemNoteService, services: true do
it_behaves_like 'cross project mentionable'
- it 'should notify about noteable being moved to' do
+ it 'notifies about noteable being moved to' do
expect(subject.note).to match /Moved to/
end
end
@@ -499,7 +499,7 @@ describe SystemNoteService, services: true do
it_behaves_like 'cross project mentionable'
- it 'should notify about noteable being moved from' do
+ it 'notifies about noteable being moved from' do
expect(subject.note).to match /Moved from/
end
end
@@ -507,7 +507,7 @@ describe SystemNoteService, services: true do
context 'invalid direction' do
let(:direction) { :invalid }
- it 'should raise error' do
+ it 'raises error' do
expect { subject }.to raise_error StandardError, /Invalid direction/
end
end
diff --git a/spec/services/test_hook_service_spec.rb b/spec/services/test_hook_service_spec.rb
index 4f47e89b4b5..4f6dd8c6d3f 100644
--- a/spec/services/test_hook_service_spec.rb
+++ b/spec/services/test_hook_service_spec.rb
@@ -6,7 +6,7 @@ describe TestHookService, services: true do
let(:hook) { create :project_hook, project: project }
describe '#execute' do
- it "should execute successfully" do
+ it "executes successfully" do
stub_request(:post, hook.url).to_return(status: 200)
expect(TestHookService.new.execute(hook, user)).to be_truthy
end
diff --git a/spec/support/select2_helper.rb b/spec/support/select2_helper.rb
index 04d25b5e9e9..35cc51725c6 100644
--- a/spec/support/select2_helper.rb
+++ b/spec/support/select2_helper.rb
@@ -11,7 +11,7 @@
#
module Select2Helper
- def select2(value, options={})
+ def select2(value, options = {})
raise ArgumentError, 'options must be a Hash' unless options.kind_of?(Hash)
selector = options.fetch(:from)
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index d2c056d8e14..baf78208ec5 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -53,7 +53,7 @@ describe 'gitlab:app namespace rake task' do
let(:gitlab_version) { Gitlab::VERSION }
- it 'should fail on mismatch' do
+ it 'fails on mismatch' do
allow(YAML).to receive(:load_file).
and_return({ gitlab_version: "not #{gitlab_version}" })
@@ -61,7 +61,7 @@ describe 'gitlab:app namespace rake task' do
to raise_error(SystemExit)
end
- it 'should invoke restoration on match' do
+ it 'invokes restoration on match' do
allow(YAML).to receive(:load_file).
and_return({ gitlab_version: gitlab_version })
expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke)
@@ -107,7 +107,7 @@ describe 'gitlab:app namespace rake task' do
end
context 'archive file permissions' do
- it 'should set correct permissions on the tar file' do
+ it 'sets correct permissions on the tar file' do
expect(File.exist?(@backup_tar)).to be_truthy
expect(File::Stat.new(@backup_tar).mode.to_s(8)).to eq('100600')
end
@@ -127,7 +127,7 @@ describe 'gitlab:app namespace rake task' do
end
end
- it 'should set correct permissions on the tar contents' do
+ it 'sets correct permissions on the tar contents' do
tar_contents, exit_status = Gitlab::Popen.popen(
%W{tar -tvf #{@backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz lfs.tar.gz registry.tar.gz}
)
@@ -142,7 +142,7 @@ describe 'gitlab:app namespace rake task' do
expect(tar_contents).not_to match(/^.{4,9}[rwx].* (database.sql.gz|uploads.tar.gz|repositories|builds.tar.gz|artifacts.tar.gz|registry.tar.gz)\/$/)
end
- it 'should delete temp directories' do
+ it 'deletes temp directories' do
temp_dirs = Dir.glob(
File.join(Gitlab.config.backup.path, '{db,repositories,uploads,builds,artifacts,lfs,registry}')
)
@@ -153,7 +153,7 @@ describe 'gitlab:app namespace rake task' do
context 'registry disabled' do
let(:enable_registry) { false }
- it 'should not create registry.tar.gz' do
+ it 'does not create registry.tar.gz' do
tar_contents, exit_status = Gitlab::Popen.popen(
%W{tar -tvf #{@backup_tar}}
)
@@ -191,7 +191,7 @@ describe 'gitlab:app namespace rake task' do
FileUtils.rm(@backup_tar)
end
- it 'should include repositories in all repository storages' do
+ it 'includes repositories in all repository storages' do
tar_contents, exit_status = Gitlab::Popen.popen(
%W{tar -tvf #{@backup_tar} repositories}
)
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index 36d03a224e4..fc52c04e78d 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -19,7 +19,7 @@ describe 'gitlab:db namespace rake task' do
end
describe 'configure' do
- it 'should invoke db:migrate when schema has already been loaded' do
+ it 'invokes db:migrate when schema has already been loaded' do
allow(ActiveRecord::Base.connection).to receive(:tables).and_return(['default'])
expect(Rake::Task['db:migrate']).to receive(:invoke)
expect(Rake::Task['db:schema:load']).not_to receive(:invoke)
@@ -27,7 +27,7 @@ describe 'gitlab:db namespace rake task' do
expect { run_rake_task('gitlab:db:configure') }.not_to raise_error
end
- it 'should invoke db:shema:load and db:seed_fu when schema is not loaded' do
+ it 'invokes db:shema:load and db:seed_fu when schema is not loaded' do
allow(ActiveRecord::Base.connection).to receive(:tables).and_return([])
expect(Rake::Task['db:schema:load']).to receive(:invoke)
expect(Rake::Task['db:seed_fu']).to receive(:invoke)
@@ -35,7 +35,7 @@ describe 'gitlab:db namespace rake task' do
expect { run_rake_task('gitlab:db:configure') }.not_to raise_error
end
- it 'should not invoke any other rake tasks during an error' do
+ it 'does not invoke any other rake tasks during an error' do
allow(ActiveRecord::Base).to receive(:connection).and_raise(RuntimeError, 'error')
expect(Rake::Task['db:migrate']).not_to receive(:invoke)
expect(Rake::Task['db:schema:load']).not_to receive(:invoke)
@@ -45,7 +45,7 @@ describe 'gitlab:db namespace rake task' do
allow(ActiveRecord::Base).to receive(:connection).and_call_original
end
- it 'should not invoke seed after a failed schema_load' do
+ it 'does not invoke seed after a failed schema_load' do
allow(ActiveRecord::Base.connection).to receive(:tables).and_return([])
allow(Rake::Task['db:schema:load']).to receive(:invoke).and_raise(RuntimeError, 'error')
expect(Rake::Task['db:schema:load']).to receive(:invoke)
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index 3647deba323..1d2cf7acddd 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -22,7 +22,7 @@ describe PostReceive do
context "branches" do
let(:changes) { "123456 789012 refs/heads/tést" }
- it "should call GitTagPushService" do
+ it "calls GitTagPushService" do
expect_any_instance_of(GitPushService).to receive(:execute).and_return(true)
expect_any_instance_of(GitTagPushService).not_to receive(:execute)
PostReceive.new.perform(pwd(project), key_id, base64_changes)
@@ -32,7 +32,7 @@ describe PostReceive do
context "tags" do
let(:changes) { "123456 789012 refs/tags/tag" }
- it "should call GitTagPushService" do
+ it "calls GitTagPushService" do
expect_any_instance_of(GitPushService).not_to receive(:execute)
expect_any_instance_of(GitTagPushService).to receive(:execute).and_return(true)
PostReceive.new.perform(pwd(project), key_id, base64_changes)
@@ -42,7 +42,7 @@ describe PostReceive do
context "merge-requests" do
let(:changes) { "123456 789012 refs/merge-requests/123" }
- it "should not call any of the services" do
+ it "does not call any of the services" do
expect_any_instance_of(GitPushService).not_to receive(:execute)
expect_any_instance_of(GitTagPushService).not_to receive(:execute)
PostReceive.new.perform(pwd(project), key_id, base64_changes)
diff --git a/vendor/gitignore/Global/VisualStudioCode.gitignore b/vendor/gitignore/Global/VisualStudioCode.gitignore
index faa18382a3c..d9960081c98 100644
--- a/vendor/gitignore/Global/VisualStudioCode.gitignore
+++ b/vendor/gitignore/Global/VisualStudioCode.gitignore
@@ -1,2 +1,4 @@
-.vscode
-
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
diff --git a/vendor/gitlab-ci-yml/Pages/Hexo.gitlab-ci.yml b/vendor/gitlab-ci-yml/Pages/Hexo.gitlab-ci.yml
index b468d79bcad..908463c9d12 100644
--- a/vendor/gitlab-ci-yml/Pages/Hexo.gitlab-ci.yml
+++ b/vendor/gitlab-ci-yml/Pages/Hexo.gitlab-ci.yml
@@ -1,25 +1,17 @@
# Full project: https://gitlab.com/pages/hexo
-image: python:2.7
-
-cache:
- paths:
- - vendor/
-
-test:
- stage: test
- script:
- - pip install hyde
- - hyde gen
- except:
- - master
+image: node:4.2.2
pages:
- stage: deploy
+ cache:
+ paths:
+ - node_modules/
+
script:
- - pip install hyde
- - hyde gen -d public
+ - npm install hexo-cli -g
+ - npm install
+ - hexo deploy
artifacts:
paths:
- public
only:
- - master
+ - master
diff --git a/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml b/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml
index 16a685ee03d..166f146ee05 100644
--- a/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml
+++ b/vendor/gitlab-ci-yml/Ruby.gitlab-ci.yml
@@ -10,6 +10,9 @@ services:
- redis:latest
- postgres:latest
+variables:
+ POSTGRES_DB: database_name
+
# Cache gems in between builds
cache:
paths:
@@ -34,6 +37,9 @@ rspec:
- rspec spec
rails:
+ variables:
+ DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
script:
- bundle exec rake db:migrate
+ - bundle exec rake db:seed
- bundle exec rake test